codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] [SPAM?] Re: PEP 558: Defined semantics for locals()


On Sun, May 26, 2019 at 8:38 AM Richard Damon <Richard at damon-family.org> wrote:
>
> On 5/25/19 5:09 PM, Nathaniel Smith wrote:
> > a = locals()
> > b = locals()
> > # now our first "snapshot" has changed
> > assert "a" in a
> >
> To me that is a static snapshot of a dynamic environment, not a dynamic
> snapshot. The snapshot you get at THAT moment in time won't change, as
> time progresses, so that snapshot itself isn't dynamic.

Except that it does. After calling locals() a second time, the result
of the *first* call will be updated to reflect changes. It's not a
frozen snapshot; you can't diff the two dictionaries to see what's
changed (unless you use "a = dict(locals())" or something, which IS a
snapshot).

>From my reading of the description, you could also "assert a is b" -
is that correct?

ChrisA