Eric V. Smith <e...@trueblade.com> added the comment:

That is interesting. See these examples. I'm starting a new interpreter each 
time:

>>> import inspect
>>> def abc(): pass
...
>>> inspect.getclosurevars(abc)
ClosureVars(nonlocals={}, globals={}, builtins={}, unbound=set())
>>>


>>> import inspect
>>> def abc(): a
...
>>> inspect.getclosurevars(abc)
ClosureVars(nonlocals={}, globals={}, builtins={}, unbound={'a'})
>>>

>>> import inspect
>>> a=0
>>> def abc(): a
...
>>> inspect.getclosurevars(abc)
ClosureVars(nonlocals={}, globals={'a': 0}, builtins={}, unbound=set())
>>>

>>> import inspect
>>> a=0
>>> def abc(): a.b
...
>>> inspect.getclosurevars(abc)
ClosureVars(nonlocals={}, globals={'a': 0}, builtins={}, unbound={'b'})
>>>

>>> import inspect
>>> a=0
>>> b=1
>>> def abc(): a.b
...
>>> inspect.getclosurevars(abc)
ClosureVars(nonlocals={}, globals={'a': 0, 'b': 1}, builtins={}, unbound=set())
>>> 

It's odd.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36697>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to