Bug in __init__?
Zbigniew Braniecki
zbigniew.braniecki at gmail.com
Fri Jan 18 12:33:20 EST 2008
Christian Heimes wrote:
> Zbigniew Braniecki wrote:
>> Any clue on what's going on here, and/if where I should report it?
>
> Congratulations! You've stumbled over a well known gotcha. Most newbies
> fall for the trap.
>
> class A:
> def __init__ (self, val=[]):
> print val
> self.lst = val
>
> val is created only *once* and shared across all instaces of A.
Thanks for help guys!
It's really a nice pitfall, I can hardly imagine anyone expecting this,
or how easily could I find this info (e.g. what query should I give to
google to get it without bothering people on this group)
Anyway, thanks :)
Greetings
Zbigniew Braniecki
More information about the Python-list
mailing list