STINNER Victor added the comment:

You can retrieve the module using sys.modules[symbol.__module__].

Example:

>>> from os import environ as ENV
>>> import imp, sys
>>> imp.reload(sys.modules[ENV.__module__])
<module 'os' from '/usr/lib64/python2.7/os.pyc'>
>>> _.environ is ENV
False

But if you import symbols instead of modules, symbols will still point to the 
old version of the module. This explain the final "False" result.

You should import modules if you want to play with reload().

I prefer to exit and restart Python instead of playing with reload, I see it as 
a hack which has many issues like "_.environ is ENV" returning False.

----------
nosy: +haypo

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

Reply via email to