The set of all global variables is known as the global environment or global state. In many languages, the scope resolution operator is written :: External variable in the c programming language, and its predecessor b, an external variable is a variable defined outside any function block
On the other hand, a local (automatic) variable is a variable defined inside a function block.
Both these rules can be overridden with a global or nonlocal (in python 3) declaration prior to use, which allows accessing global variables even if there is a masking nonlocal variable, and assigning to global or nonlocal variables.
While the term can refer to global variables, it is primarily used in the context of nested and anonymous functions where some variables can be in neither the local nor the global scope. Objects stored in a static variable (notably a global variable) may not be finalized when the program terminates, so their resources are not released Cpython makes no guarantee of finalizing such objects, for instance. See the lexical environment section below)
For example, in the following python code: A second use case would be multiple threads accumulating information into a global variable To avoid a race condition, every access to this global variable would have to be protected by a mutex.