About 135,000 results
Open links in new tab
  1. python - How do I create variable variables? - Stack Overflow

    Is it possible to do something like this in Python? What can go wrong? If you are just trying to look up an existing variable by its name, see How can I select a variable by (string) name?. …

  2. python - How can you dynamically create variables? - Stack Overflow

    I want to create variables dynamically in Python. Does anyone have any creative means of doing this?

  3. python - Using a string variable as a variable name - Stack Overflow

    Jul 19, 2012 · I have a variable with a string assigned to it and I want to define a new variable based on that string.

  4. python - How to assign a variable in an IF condition, and then …

    Apr 27, 2019 · The one liner doesn't work because, in Python, assignment (fruit = isBig(y)) is a statement, not an expression. In C, C++, Perl, and countless other languages it is an …

  5. python - Convert dictionary entries into variables - Stack Overflow

    Consider the "Bunch" solution in Python: load variables in a dict into namespace. Your variables end up as part of a new object, not locals, but you can treat them as variables instead of dict …

  6. Python Variable Declaration - Stack Overflow

    Jun 13, 2012 · The idiomatic way to create instance variables is in the __init__ method and nowhere else — while you could create new instance variables in other methods, or even in …

  7. Python: copy of a variable - Stack Overflow

    Nov 24, 2012 · Is there a way in to make copy of a variable so that when the value changes of variable 'a' it copies itself to variable 'b'? Example a='hello' b=a #.copy() or a function that will …

  8. python - How do you create different variable names while in a …

    How do you create different variable names while in a loop? [duplicate] Asked 14 years, 5 months ago Modified 5 years, 4 months ago Viewed 698k times

  9. Convert string to variable name in python - Stack Overflow

    47 This is the best way, I know of to create dynamic variables in python. my_dict = {} x = "Buffalo" my_dict[x] = 4 I found a similar, but not the same question here Creating dynamically named …

  10. How do I create a multiline Python string with inline variables?

    Alternatively, you can also create a multiline f-string with triple quotes where literal newlines are considered part of the string. However, any spaces at the start of the line would also be part of …