[Edu-sig] Pass by Reference
John Posner
jjposner at snet.net
Tue May 20 16:50:38 CEST 2008
> ... 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
More information about the Edu-sig
mailing list