On Thu, May 28, 2020 at 8:01 PM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Wed, May 27, 2020 at 05:03:09AM +1000, Chris Angelico wrote:
>
> > def foo():
> >     if False: x = 0
> >     # what is x now?
> >
> > There is no *value* in x, yet x has a state.
>
> In Python code, no, it has no state, it's just an unbound name. That's
> literally a name that has nothing bound to it, hence no state.
>

Is the UnboundLocalError that you'd get on trying to access 'x' a
CPython implementation detail or a language feature? If it's a
language feature, then the name 'x' must be in the state of "local
variable without a value". This is a valid situation. There is no
value, but this is the state of the variable. It's not "no state" any
more than zero is a non-number or NULL is a non-pointer.

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/KLTFG3E7WB5R42OWJ3NL2VQ6NSTJO5CK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to