Agreed. 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.
Warren Sande ----- Original Message ---- From: John Posner <[EMAIL PROTECTED]> To: edu-sig@python.org Sent: Tuesday, May 20, 2008 10:50:38 AM Subject: Re: [Edu-sig] Pass by Reference > ... and stop trying to invent new names for a parameter passing mechanism > that is identical in function to traditional call by value. > Yeah, but ... it will be difficult to stick to a call-by-value characterization when confronted with this example, which is straight from "Call by Reference 101": def AddArtist(mylist): mylist.append('TheOtherTerry') >>> troupe ['Graham', 'John', 'Eric', 'Michael', 'Terry'] >>> AddArtist(troupe) >>> troupe ['Graham', 'John', 'Eric', 'Michael', 'Terry', 'TheOtherTerry'] Most students (especially newbies) won't care about what happens under the hood -- not at first. If it looks like a duck, walks like a duck, and quacks like a duck ... -John _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig