On 7 sep, 12:40, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Jan Schäfer wrote: > > can anyone explain the behaviour of the following code sniplet: > > well, it *is* explained in the tutorial, the language reference, and the > FAQ, so yes, it can be explained ;-) > > for more information, see this page: > > http://effbot.org/zone/default-values.htm > > </F>
Well, you may want replace the last line by: print ivar, obj, obj.varlist, id(obj.varlist) To have another behavior, you may want replace the 3 first lines by: class Base(object): def __init__( self, lst=None ): if lst is None: lst=[] self.varlist = lst Enjoy Python ! -- http://mail.python.org/mailman/listinfo/python-list