the global keyword:

Chris Angelico rosuav at gmail.com
Thu Jun 23 21:19:52 EDT 2016


On Fri, Jun 24, 2016 at 11:00 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> To me, a global variable is a variable which is scoped to a level wider than
> any single function, i.e. module scope, or whole-application scope. That
> is, the variable must be visible to more than one function, or more than
> one module.

... and not part of a closure, because they're not global. (I'd also
say "nor part of an object", but objects in Python have attributes
accessed using 'self.', so your other check removes that. But in C++,
that would need to be another criterion.)

ChrisA



More information about the Python-list mailing list