Pass by reference ?

Daniel Berlin dan at
Thu Apr 6 01:48:27 CEST 2000

>    def Nuke(w):
>      print w,
>      w=None
>      print w

Sorry, this function is not a good demonstration.
w is a reference to whatever is passed in.
Then you are making w a reference to None.
What you should try is w.append(5), or something

Try thusly:
def Appender(w):
	print w
	print w
Now, let's call this:


You'll see:
Then, if you print x, you'll see:

Thus, we passed it by reference, because it modified the original.
> This behavior meets the classical definition of "Pass By Value".

Bad example.

> What other tests have I omitted, and what do they yield?
See above.

> -BobC
> -- 

More information about the Python-list mailing list