Duncan Booth a écrit :
(snip)
> I think what you want for Bar is something more along the lines:

(snip)

> class Bar(Foo):
>     def __new__(cls, a, b, c, *args):
>         print 'Bar.__new__', len(args)
>         target = cls
You don't use 'target' anywhere...

>         if not args:
>             cls = Zoo
>         obj = super(Bar, cls).__new__(cls, a, b, c, *args)
>         if args:
>             return obj
> 
>         obj.__init__(a, b, c, 7)

IIRC, __new__ is supposed to return the newly created object - which you 
are not doing here.

class Bar(Foo):
     def __new__(cls, a, b, c, *args):
         print 'Bar.__new__', len(args)
         if not args:
             cls = Zoo
         obj = super(Bar, cls).__new__(cls, a, b, c, *args)
         if not args:
             obj.__init__(a, b, c, 7)
         return obj


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

Reply via email to