Why read-only nested scopes?
op73418 at mail.telepac.pt
Wed Sep 4 22:25:45 CEST 2002
On Wed, 4 Sep 2002 19:46:49 GMT, Andrew Koenig <ark at research.att.com>
>Gonçalo> Anyway, I've been directed to PEP 227, cheerfully obeyed, and
>Gonçalo> from what I have understood having read-only nested scopes
>Gonçalo> was more of a design decision than something else. And while
>Gonçalo> I can live happily with the decision (some would even say
>Gonçalo> happier) there is something about the "You can look at it but
>Gonçalo> not touch it" attitude that I dislike ;-)
>You can do anything to the object that the object support.
>What you can't do is change the binding of the name.
Yes, I am aware of this. You can even wrap x in a list and then modify
the list to indirectly change x, but it was the rebinding that I was
refering to, so let me rephrase the above to "You can look at it AND
even touch it but ONLY if suitably dressed" :-)
> x = 
> def foo(y):
>After executing this code, x is [3, 4, 5].
All the best,
More information about the Python-list