About 361,000 results
Open links in new tab
  1. How can I use a global variable in a function? - Stack Overflow

    Jul 11, 2016 · How do I create or use a global variable inside a function? How do I use a global variable that was defined in one function inside other functions? Failing to use the global …

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

  3. How to declare a global variable in Python correctly

    Jan 28, 2023 · 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 …

  4. How to set a global variable in Python - Stack Overflow

    Ok, so I've been looking around for around 40 minutes for how to set a global variable on Python, and all the results I got were complicated and advanced questions and more so answers. I'm …

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

  6. Make all variables in a Python function global - Stack Overflow

    Jul 21, 2012 · Is there a simple way to make all variables in a function global? I have 20 odd variables in a function and naming them global one by one doesn't make nice code... to me …

  7. How do you declare a global constant in Python?

    Jun 10, 2014 · My program contains multiple files and classes, and I would like to be able to access this variable from anywhere, and if possible define it as constant. How do you define a …

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

    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 …

  9. Crear variables globales en Python - Stack Overflow en español

    Jul 19, 2019 · Yo soy bastante nuevo con la sintaxis de Python en particular como crear global, nonlocal y local variables y como declararlas sin errores de sintaxis. Por ejemplo en el …

  10. Python - Easiest way to define multiple global variables

    Dec 6, 2016 · The reason for this is that python treats classes as modules, so this works out well for setting up a list of global variables- such as when trying to make an interface with multiple …