Passing arguments to function - (The fundamentals are confusing me)

Rocco Moretti roccomoretti at hotpop.com
Tue Aug 9 11:39:29 EDT 2005


Christopher Subich wrote:
> Gregory Piñero wrote:
> 
>> Hey guys, would someone mind giving me a quick rundown of how
>> references work in Python when passing arguments into functions?  The
>> code below should highlight my specific confusion:

This URL is always tossed out:

http://starship.python.net/crew/mwh/hacks/objectthink.html

> All arguments are passed by reference, but in Python equality rebinds 
> the name.

Bingo

>> Why does my list variable get changed for the rest of the program, but
>> my boolean variable doesn't.  What am I not understanding?

Booleans are immutable, lists are mutable. You change (mutate) the same 
list, but you are referencing a different (immutable) Bool

> In Python, "x = y" has a very definite meaning of "y is assigned to the 
> name of x."  

Change it to "the object referenced by y is assigned to the name of x", 
and you're closer to the truth.



More information about the Python-list mailing list