About 382,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

    Sep 18, 2021 · I want to create variables dynamically in Python. Does anyone have any creative means of doing this?

  3. 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 …

  4. 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.

  5. How can I use a global variable in a function? - Stack Overflow

    Jul 11, 2016 · In Python, the module is the natural place for global data: Each module has its own private symbol table, which is used as the global symbol table by all functions defined in the …

  6. 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 …

  7. 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 …

  8. Python: copy of a variable - Stack Overflow

    Nov 24, 2012 · a='hello' b=a #.copy() or a function that will make a copy a='bye' # Is there a way to make # 'b' equal 'a' without # doing 'b=a' print a print b I am having a problem using the …

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

    buffalo=4 not only this example, I want to convert any input string to some variable name. How should I do that (in python)?

  10. How to create module-wide variables in Python? [duplicate]

    Dec 30, 2009 · If you assign the variable without the global keyword then Python creates a new local var -- the module variable's value will now be hidden inside the function.