Nested function scope problem

Gerhard Fiedler gelists at gmail.com
Tue Jul 25 09:30:20 EDT 2006


On 2006-07-25 04:06:24, Steve Holden wrote:

> Dennis Lee Bieber wrote:
>> On Mon, 24 Jul 2006 17:35:50 -0300, Gerhard Fiedler <gelists at gmail.com>
>> declaimed the following in comp.lang.python: 
>> 
>>> It is surprising in the sense that binding seems not to be necessary
>>> for read access. 
>>
> It does, I would agree, seem a little counter-intuitive that assignment
> (or binding) forces the name to be considered local. That's just one of
> Python's features.

Ok... I can live with that, and thanks for the confirmation that it's not
only me to feel that this is somewhat surprising :)

Surprising for me are actually two things: 1- the fact itself, and 2- that
term "binding", and that whatever it means (I'll have to read more on that,
now that I know the term) is different for read-only and read/write access.

Neither the Post-It note metaphor nor the pointer explanation address that.
Using the Post-It note metaphor, I'm asking myself why the label doesn't
get attached to a different box when reading, but only when writing. ("Just
one of Python's features", I know :)  Same thing with the pointer
explanation: AFAIK, no language that uses pointers explicitly does
something similar (that is, the storage the pointer points to is different
depending on whether the pointer gets used for writing and reading, or only
for reading). 

Thanks,
Gerhard




More information about the Python-list mailing list