Easy questions from a python beginner

Rami Chowdhury rami.chowdhury at gmail.com
Mon Jul 12 18:14:52 EDT 2010


Perhaps I'm misunderstanding, but ...

On Jul 12, 2010, at 13:57 , Alf P. Steinbach /Usenet wrote:
> 
> Existence of a variable means, among other things, that
> 
>  * You can use the value, with guaranteed effect (either unassigned exception
>    or you get a proper value)

Surely by that definition any variable in any Python program "exists" -- you are guaranteed to get one of NameError, UnboundLocalError, or a value. That seems to argue away the meaning of the word entirely, and renders it not particularly useful.

> 
> How the Python implementation implements that is an implementation detail.
> 
> In short, how CPython does things is completely irrelevant to the language's semantics, so you're conflating things here.
> 

As I'd understood the previous discussion, it is the CPython implementation that reserves local names and produces UnboundLocalErrors. The language semantics don't call for it, and another implementation might choose to handle function locals the same way as globals, through a namespace dictionary -- in which case the variable *wouldn't* exist in any way, shape, or form until it was assigned to.

What am I getting wrong here?

-------------
Rami Chowdhury
"Never assume malice when stupidity will suffice." -- Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)





More information about the Python-list mailing list