Steven D'Aprano wrote:
> We could rescue the concept by saying that any reference to locals() inside
> the function disables the elimination, but of course locals can be shadowed
> or aliased, and we can't expect the interpreter to do a full analysis of the
> entire program.
We already do something similar for zero-argument super():
>>> duper = super
>>> class C:
... def __init__(self):
... duper()
...
>>> C()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __init__
RuntimeError: super(): __class__ cell not found
Besides, locals() is already a bit weird at best:
>>> [locals() for _ in [None]]
[{'.0': <tuple_iterator object at 0x7ffa6c609280>, '_': None}]
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/XP42EASH6VVZOCUTEAJVRUNBOZRXO4ZT/
Code of Conduct: http://python.org/psf/codeofconduct/