About 50 results
Open links in new tab
  1. python - 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 keyword where …

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

  3. 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 global varia...

  4. When do I need to use the global keyword in python

    Aug 8, 2012 · However, when that line is encountered inside a function, it creates a local reference bar unless you say global bar. In effect, you have two different variables named bar: the global and the …

  5. Python global keyword - Stack Overflow

    Jul 28, 2017 · I am confused with the global keyword behavior in below code snippet, I was expecting 30, 30, 30 in all 3 prints. def outer_function(): #global a ###commented intentionally a = 20 def

  6. About the global keyword in python - Stack Overflow

    Apr 13, 2012 · Python uses fairly typical variable scoping. Non-local variables are visible within a function. You only need global keyword if you want to assign to a variable within global scope. Also …

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

    Defining a variable on the module level makes it a global variable, you don't need the global keyword. The second example is correct usage. However, the most common usage for global variables are …

  8. python - Global dictionaries don't need keyword global to modify …

    59 The reason is that the line stringvar = "bar" is ambiguous, it could be referring to a global variable, or it could be creating a new local variable called stringvar. In this case, Python defaults to assuming it …

  9. python - What is the difference between non local variable and global ...

    Oct 19, 2015 · I'm learning the concepts of programming languages. I found the terminology "nonlocal" in python syntax. What is the meaning of nonlocal in python?

  10. Global keyword in python: why, reputation and ¿real use?

    Dec 11, 2018 · However, my thoughts are the following: 1) The global keyword must be there for some reasons. ¿Which were the reasons to include it in python core? 2) Regarding its reputation and the …