On Sat, May 30, 2020 at 6:13 PM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Sat, May 30, 2020 at 04:34:49PM +1200, Greg Ewing wrote:
> > On 30/05/20 12:11 am, Steven D'Aprano wrote:
> > >I said that the storage mechanism of *how* local variables are stored,
> > >and hence whether or not writes to `locals()` are reflected in the
> > >local variables, is an implementation detail.
> >
> > That's true, but just to be clear, my ?= idea doesn't rely on
> > that implementation detail. If locals were kept in a dict, for
> > example, it could work by testing whether the name has an
> > entry in the dict.
>
> This thread is huge and I'm losing track of who said what and what they
> meant by it. I thought `?=` was Chris' idea :-)

I was talking about a somewhat similar notion of being able to cleanly
ask the question "is this variable bound to anything", but the ideas
have been broadly similar and it's not easy to figure out who said
what :)

> Some people (Alex, Chris I think?) have tried to argue that there is a
> distinction between an unbound variable and a variable that doesn't
> exist at all, but I'm not clear what they think that distinction would
> be, or why (if such a distinction exists) the interpreter doesn't tell
> when it's one or the other:
>
>     NameError: name 'grue' is not defined
>     NameError: name 'bleen' doesn't exist at all
>

The difference would be that, when a local variable doesn't exist, a
global or builtin is searched for. That's very different from the
local existing but having no value. Local scope is the only one where
this happens, but it's kinda slightly important, given how much Python
code executes at that scope :)

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/COBOZHXLOTLNM6H5AXE55JNKD7LND7EO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to