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

Gregory Piñero gregpinero at gmail.com
Tue Aug 9 16:53:15 CEST 2005


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:

<code>

bool1=True
lst1=[1,2,3]

def func1(arg1): arg1.append(4)

def func2(arg1): arg1=False

>>func1(lst1)
>>lst1
[1,2,3,4]

>>func2(bool1)
>>bool1
True

</code>

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

-- 
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)



More information about the Python-list mailing list