About 414,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. Correct Use Of Global Variables In Python 3 - Stack Overflow

    Feb 20, 2012 · Which is the correct use of global variables in Python 3?: 1) Stating global VAR_NAME once in the core script (not within a function) and then simply referring to the …

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

  4. How to declare a global variable in Python correctly

    Jan 28, 2023 · I have the following piece of code that presented below with tic-tac-toe implementation. As far as I understand variable "player" is global one and it's value …

  5. Why does assigning to my global variables not work in Python?

    To mark a variable as global you need to use the global keyword in Python, in the scope that you want to use the global variable. In this case that is within the setA (value) function.

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

    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 …

  7. How can I access global variable inside class in Python

    May 30, 2012 · How can I access global variable inside class in Python Asked 13 years, 7 months ago Modified 28 days ago Viewed 286k times

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

  9. python - Why are global variables evil? - Stack Overflow

    Oct 3, 2013 · Why is the global keyword considered bad practice in Python (and programming in general)? Links with more information would also be appreciated.

  10. python - How can I change a global variable from within a …

    The a in your first line is a global variable (so called because it exists in the global scope, outside of any function definitions). The a in the other lines is a local variable, meaning that it only …