[Python-ideas] Unpacking a dict
pavol.lisy at gmail.com
Sun May 29 13:49:08 EDT 2016
Sorry I just tried to help understand why it is wrong idea. :)
But (and sorry it is another story) what surprised me during my
analysis of this problem is that import variable from module is more
likely unpacking value than getting access to module's variable.
VAR = 1
VAR = a
from my_test import VAR, setter, getter
print(VAR) # 1
print(getter()) # 1
print(VAR) # 1 !
print(getter()) # 7
from my_test import VAR
print(VAR) # 7 !
The more I understand python the more I see that I don't understand enough. :)
2016-05-29 19:23 GMT+02:00, Guido van Rossum <guido at python.org>:
> Any idea using import syntax or even syntax similar to import is dead.
> Import is about modules and needs to stay about that.
> On Sun, May 29, 2016 at 10:10 AM, Pavol Lisy <pavol.lisy at gmail.com> wrote:
>> I see backward compatibility problem with import :
>> sys = dict(version_info=4.0)
>> from sys import version_info
>> This is legal and using import for unpacking dict could change this
>> In case we put higher priority to import from module then unexpected
>> module in PYTHONPATH could change unpacked value. Sort of problem not
>> easy to found. From library maintainer point of view not easy to avoid
>> Python-ideas mailing list
>> Python-ideas at python.org
>> Code of Conduct: http://python.org/psf/codeofconduct/
> --Guido van Rossum (python.org/~guido)
More information about the Python-ideas