
showell30 at yahoo
Nov 22, 2009, 3:14 PM
Post #3 of 7
(312 views)
Permalink
|
|
Re: problem manipulating a list belonging to a class
[In reply to]
|
|
On Nov 22, 2:50 pm, Marc Leconte <marcg...@free.fr> wrote: > Dear all, > > I have a problem with the following code (ubuntu 8.04, Python 2.5.2): > > class Toto(object): > def __init__(self, number, mylist=[]) > self.number=number > self.mylist=mylist > pass > pass > Change your code to do this: def __init__(self, number, mylist=None): if mylist is None: self.mylist = [] else: self.mylist = mylist Explanations of why you need to write it that will follow... -- http://mail.python.org/mailman/listinfo/python-list
|