On Sun, 11 Mar 2001, Tim Peters wrote: > OK by me. Note that we agreed long ago that if nested scopes ever made it > in, we would need to supply a way to get a "namespace mapping" object so that > stuff like: > > print "The value of i is %(i)s and j %(j)s" % locals() > > could be replaced by: > > print "The value of i is %(i)s and j %(j)s" % namespace_map_object() I remarked to Jeremy at Python 9 that, given that we have new variable lookup rules, there should be an API to perform this lookup. I suggested that a new method on frame objects would be a good idea, and Jeremy & Barry seemed to agree. I was originally thinking of frame.lookup('whatever'), but if that method happens to be tp_getitem, then i suppose print "i is %(i)s and j is %(j)s" % sys.getframe() would work. We could call it something else, but one way or another it's clear to me that this object has to follow lookup rules that are completely consistent with whatever kind of scoping is in effect (i.e. throw out *both* globals() and locals() and provide one function that looks up the whole set of visible names, rather than just one scope's contents). -- ?!ng "Computers are useless. They can only give you answers." -- Pablo Picasso
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4