[Python-Dev] Early PEP draft (For Python 3000?)

Calvin Spealman ironfroggy at gmail.com
Fri Oct 14 08:16:16 CEST 2005

On 10/11/05, Eyal Lotem <eyal.lotem at gmail.com> wrote:
>       locals()['x'] = 1 # Quietly fails!
> Replaced by:
>       frame.x = 1 # Raises error

What about the possibility of making this hypothetic frame object an
indexable, such that frame[0] is the current scope, frame[1] is the
calling scope, etc.? On the same lines, what about closure[0] for the
current frame, while closure[1] resolves to the closure the function
was defined in? These would ensure that you could reliably access any
namespace you would need, without nasty stack tricks and such, and
would make working around some of the limitation of the closures, when
you have such a need. One might even consider a __resolve__ to be
defined in any namespace, allowing all the namespace resolution rules
to be overridden by code at any level.

More information about the Python-Dev mailing list