Nested scopes, and augmented assignment

Bruno Desthuilliers onurb at xiludom.gro
Fri Jul 7 06:43:30 EDT 2006


Antoon Pardon wrote:
> On 2006-07-06, Piet van Oostrum <piet at cs.uu.nl> wrote:
> 
> 
>>>AP> Aren't we now talking about implementation details? Sure the compilor
>>>AP> can set things up so that local names are bound to the local scope and
>>>AP> so the same code can be used. But it seems somewhere was made the
>>>AP> decision that b was in the local scope without looking for that b in
>>>AP> the scopes higher up.
>>
>>Yes, as I (and others) have already said several times: an assignment to a
>>variable inside a function body (but not an assignment to an attribute or
>>part of an object) without a global declaration makes that variable a local
>>variable. That is not an implementation detail; it is part of the language definition.
> 
> 
> You seem to think I didn't understand this. 

And he's right, cf below.

(snip)

> Could you maybe clarify what problem we are discussing? All I wrote
> was that with an assignment the search for the lefthand variable
> depends on whether the lefthand side is a simple variable or
> more complicated.

You're obviously clueless. Which would not be a problem if you did not
refuse to first aknowledge the fact then take appropriate actions.

> Sure people may prefer to speak about (re)binding
> vs mutating variables, but just because I didn't use the prefered terms,

If you refuse to understand that there are pretty good reasons to use
the appropriate semantic, that's your problem, but then no one can help
you.

> starting to doubt my understanding of the language, seems a bit
> premature IMO.

I do not 'doubt', I'm 111% confident.

> I'm sure there are areas where my understanding of
> the language is shaky, metaclasses being one of them, but understanding
> how names are searched doesn't seem to be one of them.

It is, obviously.

And you're definitively a crank.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list