<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">Agreed. <br><br>Python "behaves like" call-by-value for immutable types and "behaves like" call-by-reference for mutable types. Newbies care about how a thing behaves, not what's going on behind the scenes. Because understanding the behavior lets them write working programs. This seemingly inconsistent behavior is one thing that makes teaching with Python a bit more difficult. Beginners want the answer to the question: "If I pass something to a function, can the function change it or not?" And the answer is, "It depends." That's not a great answer for a beginner.<br><br>Warren Sande<br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">-----
Original Message ----<br>From: John Posner <jjposner@snet.net><br>To: edu-sig@python.org<br>Sent: Tuesday, May 20, 2008 10:50:38 AM<br>Subject: Re: [Edu-sig] Pass by Reference<br><br>> ... and stop trying to invent new names for a parameter passing mechanism<br>> that is identical in function to traditional call by value.<br>> <br><br>Yeah, but ... it will be difficult to stick to a call-by-value<br>characterization when confronted with this example, which is straight from<br>"Call by Reference 101":<br><br>def AddArtist(mylist):<br> mylist.append('TheOtherTerry')<br> <br>>>> troupe<br>['Graham', 'John', 'Eric', 'Michael', 'Terry']<br><br>>>> AddArtist(troupe)<br><br>>>> troupe<br>['Graham', 'John', 'Eric', 'Michael', 'Terry', 'TheOtherTerry']<br><br><br>Most students (especially newbies) won't care about what happens under the<br>hood -- not at first. If it looks like a duck, walks like a duck, and
quacks<br>like a duck ...<br><br>-John<br><br>_______________________________________________<br>Edu-sig mailing list<br><a ymailto="mailto:Edu-sig@python.org" href="mailto:Edu-sig@python.org">Edu-sig@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/edu-sig" target="_blank">http://mail.python.org/mailman/listinfo/edu-sig</a><br></div><br></div></div></body></html>