About the implementation of del in Python 3

Steve D'Aprano steve+python at pearwood.info
Fri Jul 7 01:43:19 EDT 2017


On Fri, 7 Jul 2017 07:46 am, Chris Angelico wrote:

> A simple name lookup cannot, I believe, be messed with. Nor can a literal.

In principle, you could replace builtins or globals with a custom namespace that
performed some computation on name lookup. You might even be able to insert
some additional namespaces between locals and globals.

Using eval or exec, you can pass an arbitrary mapping as globals and locals.

But "ordinary" name lookup in locals of a function, or the standard module
globals, cannot do anything funny.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list