On Jan 18, 2008 12:33 PM, Zbigniew Braniecki <[EMAIL PROTECTED]> wrote: > > 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)
In this unfortunate case, useful searches were "default arguments", which would be hard to guess without already knowing what's going wrong, or "python gotchas pitfalls", which is a good general purpose search for when you can't understand what's happening in simple code. -- Neil Cerutti <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list