Totally Confused: Passing variables to functions

Erik Max Francis max at alcyone.com
Thu Jun 5 04:41:51 EDT 2003


Chuck wrote:

> I've hit a stumbling block while trying to pick up Python. I've
> googled
> around, and I don't think I'm the first to have this question, but I
> haven't
> been able to find an answer that explains things for me.

The difference you've found is that lists are mutable but integers are
not.  So modifying a mutable object in a function causes changes as seen
by the caller (since it's the same object on both sides), but rebinding
an immutable object doesn't, since all names are local (except when set
off by the "global" statement).

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ You're a fighter, so fight / Wake up and live
\__/  Sweetbox




More information about the Python-list mailing list