About 641,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?. However, first …

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

  3. python - How to make a local variable (inside a function) global ...

    I'm using functions so that my program won't be a mess but I don't know how to make a local variable into global.

  4. How to declare a global variable in Python correctly

    Jan 28, 2023 · 3 If a function assigns to a variable name (which your greet() function does for the player variable), then that variable name is treated as local everywhere in the function, even if there is a …

  5. 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)?

  6. python - Using global variables between files? - Stack Overflow

    25 You can think of Python global variables as "module" variables - and as such they are much more useful than the traditional "global variables" from C. A global variable is actually defined in a module's …

  7. Is it possible only to declare a variable without assigning any value ...

    Mar 20, 2009 · Is it possible to declare a variable in Python, like so?: var so that it initialized to None? It seems like Python allows this, but as soon as you access it, it crashes. Is this possible? If not, ...

  8. python - Class (static) variables and methods - Stack Overflow

    Sep 16, 2008 · Although it doesn't say anything specific about static variables or methods, the Python tutorial has some relevant information on classes and class objects. @Steve Johnson also answered …

  9. How to create module-wide variables in Python? - Stack Overflow

    Dec 30, 2009 · Here is what is going on. First, the only global variables Python really has are module-scoped variables. You cannot make a variable that is truly global; all you can do is make a variable in …

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