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

    Jul 11, 2016 · In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a new value anywhere within the function’s body, it’s assumed to be a …

  2. Python function global variables? - Stack Overflow

    150 Within a Python scope, any assignment to a variable not already declared within that scope creates a new local variable unless that variable is declared earlier in the function as referring …

  3. Correct Use Of Global Variables In Python 3 - Stack Overflow

    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 variable as VAR_NAME …

  4. How to declare a global variable in Python correctly

    Jan 28, 2023 · How to declare global variables in a correct way in Python? What I'm doing wrong? I expected the code of tic-tac-toe working correctly but it didn't. To resolve the issue I tried to …

  5. python - Why isn't the 'global' keyword needed to access a global ...

    From my understanding, Python has a separate namespace for functions, so if I want to use a global variable in a function, I should probably use global. However, I was able to access a …

  6. ¿Cómo usar variables globales en python? - Stack Overflow en …

    0 Verán quisiera saber como hacer para que las funciones que utilizo en python tomen el valor de las variables globales, y como hago para que esas variables conserven el valor que les asigno …

  7. python - Variables declared outside function - Stack Overflow

    In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a value anywhere within the function’s body, it’s assumed to be local unless explicitly …

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

  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 - Performance with global variables vs local - Stack Overflow

    32 I am still new to Python, and I have been trying to improve the performance of my Python script, so I tested it with and without global variables. I timed it, and to my surprise, it ran faster …