A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-March/013475.html below:

[Python-Dev] Deprecating locals() (was Re: nested scopes and global: some corner cases)

[Python-Dev] Deprecating locals() (was Re: nested scopes and global: some corner cases)Samuele Pedroni Samuele Pedroni <pedroni@inf.ethz.ch>
Mon, 12 Mar 2001 21:23:25 +0100 (MET)
Hi.

[GvR]
> > I imagine a (new) function that produce a snap-shot of the values in the
> > local,free and cell vars of a scope can do the job required for simple 
> > debugging (the copy will not allow to modify back the values), 
> > or another approach...
> 
> Maybe.  I see two solutions: a function that returns a copy, or a
> function that returns a "lazy mapping".  The former could be done as
> follows given two scopes:
> 
> def namespace():
>     d = __builtin__.__dict__.copy()
>     d.update(globals())
>     d.update(locals())
>     return d
> 
> The latter like this:
> 
> def namespace():
>     class C:
>         def __init__(self, g, l):
>             self.__g = g
>             self.__l = l
>         def __getitem__(self, key):
>             try:
>                 return self.__l[key]
>             except KeyError:
>                 try:
>                     return self.__g[key]
>                 except KeyError:
>                     return __builtin__.__dict__[key]
>     return C(globals(), locals())
> 
> But of course they would have to work harder to deal with nested
> scopes and cells etc.
> 
> I'm not sure if we should add this to 2.1 (if only because it's more
> work than I'd like to put in this late in the game) and then I'm not
> sure if we should deprecate locals() yet.
But in any case we would need something similar to repair pdb,
this independently of locals deprecation...

Samuele.




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