3 ms·
I'm not sure exactly, but my point is that a program transformation can do it. However, no transformation can change an import to other operations while perserv
by akvadrako 8y ago
I'm not sure exactly, but my point is that a program transformation can do it. However, no transformation can change an import to other operations while perserving semantics.
Just for fun, this seems to work:
(locals().pop('x', None), locals().setdefault('x', y))[1]
- yorwba 8y agoThat only works at top-level scope, where locals() == globals(). Inside a function, changing the dict returned by locals() doesn't actually change the variable.