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

Reply via email to