En Thu, 05 Apr 2007 14:13:43 -0300, Manuel Graune <[EMAIL PROTECTED]>
escribió:
> class new_class(object):
> def __init__( self,
> internal_list=[]):
> self.internal_list= internal_list
All your instances share the *same* internal list, because default
arguments are evaluated only once (when the function is defined)
The usual way is to write:
class new_class(object):
def __init__(self, internal_list=None):
if internal_list is None:
internal_list = []
self.internal_list= internal_list
See
http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list