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

    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. How to define global function in Python? - Stack Overflow

    Jan 13, 2015 · Is there a way to define a function to be global from within a class( or from within another function, as matter of fact)? Something similar to defining a global variable.

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

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

  5. In Python what is a global statement? - Stack Overflow

    Dec 14, 2012 · What is a global statement? And how is it used? I have read Python's official definition; however, it doesn't make a lot of sense to me.

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

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

    May 30, 2012 · for i in range(10): g_c = 1 print(g_c) The statement tells the Python compiler that any assignments (and other binding actions) to that name are to alter the value in the global …

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

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

    This one line addition tells Python that when you use the variable a in the setA (value) function that you are talking about the global variable, not a local variable.

  10. create a global function in python - Stack Overflow

    Apr 2, 2013 · In python how can I create a function that can be global an used in all classes that are called? Here is an example: import configparser import os import sys from datetime import …