Newbie question - default values of a function
Bulba!
bulba at bulba.com
Wed Dec 22 17:37:37 EST 2004
On Wed, 22 Dec 2004 22:29:44 GMT, "Matt Gerrans" <matt.gerrans at hp.com>
wrote:
>Actually i was not mutable. Try this:
>i = 1
>id(i)
>i += 1
>id(i)
Looks like I will have to read the Language Reference anyway. :-(
<snip, thanks>
>Because you are assigning the local reference variable L to a new list,
>instead of modifying that original default list that was created.
>Is that more clear, or is it now more unclear? ;)
Clear now, but I have to say for someone who's been doing
some C programming in the past it is pretty confusing, because
I'm used to think of any variable as basically a place in memory
with a pointer to it, so anything without #define or const was
considered "mutable" (gawd I still hate pointers).
C-style thinking considered harmful when programming in Python. :o)
--
It's a man's life in a Python Programming Association.
More information about the Python-list
mailing list