Alan Isaac wrote:

> class NothingNew:
>     a = 0
>     def __init__(self):
>         self.b = 1
>         self.initialized = True

There's a problem with that when you want to subclass:

   class NothingElseNew(NothingNew):

     def __init__(self):
       NothingNew.__init__(self)
       self.c = 42 # <--- Not allowed!

You could get around this by temporarily de-initializing
it, i.e.

     def __init__(self):
       NothingNew.__init__(self)
       del self.__dict__['initialized']
       self.c = 42
       self.initialized = True

but that's not very elegant.

--
Greg
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to