This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients
Date 2005-09-23.22:01:09
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.



History
Date User Action Args
2008-01-20 09:58:10adminlinkissue1296434 messages
2008-01-20 09:58:10admincreate