why cannot assign to function call

Rhodri James rhodri at wildebst.demon.co.uk
Sat Feb 28 01:08:30 CET 2009

On Fri, 27 Feb 2009 23:55:43 -0000, Ethan Furman <ethan at stoneleaf.us>  

I'm not Mark, but you did post to the whole group!

[snippety snip]

> Specifically, how is a new name (pbr) different, in Python, from a new  
> name initialized as if by assignment (pbv)?  It seems to me than you end  
> up with the same thing in either case (in Python, at least), making the  
> distinction non-existent.
> def func(bar):
>      bar.pop()
> Pass-by-reference:
>    foo = ['Ethan','Furman']
>    func(foo)			# bar = foo
> Pass-by-value:
>    foo = ['Python','Rocks!']
>    func(foo)			# bar is new name for foo

With true pass-by-value, this comment is not true.  Bar would be a copy
of foo, not a new name.  What happens to bar is then not reflected in
foo (depending on how deep the copy is), which is the objective of

Rhodri James *-* Wildebeeste Herder to the Masses

More information about the Python-list mailing list