On Fri, Mar 11, 2016 at 2:13 AM, Charles T. Smith
<[email protected]> wrote:
> When might a "global" statement be used in the outermost level of a module?
You wouldn't need this in a normal module, because locals and globals
are the same. It may be useful if you're using exec with separate
locals and globals, and need to set a global. For example:
source = 'global y; x, y = 1, 2'
gvars, lvars = {}, {}
exec(source, gvars, lvars)
>>> lvars
{'x': 1}
>>> gvars['y']
2
Probably you'll never need this.
--
https://mail.python.org/mailman/listinfo/python-list