Message60817
Logged In: YES
user_id=593130
I agree that there are problems of beginners misunderstanding
Python's object model. However, the proposed fix is not exactly
correct. Python *always* calls functions by binding local
parameter names to argument objects or lists or dicts thereof.
Whenever a name is rebound to a new object, it is *always*
unbound from the previous object, as it must be. Mutability is
irrelevant. So is localness induced by a function call.
Changing locality and mutability, your example is equivalent to
a = 1
val = a
val = val + 1
a = [1]
val = a
val = val + [2]
# or
def f(val):
val = val + [2]
f(a)
*all* of which leave 'a' unchanged, but all of which a beginner
might think change 'a'. Perhaps you can suggest a different
rewording.
|
|
Date |
User |
Action |
Args |
2008-01-20 09:58:10 | admin | link | issue1296434 messages |
2008-01-20 09:58:10 | admin | create | |
|