A simpler super.
Syver Enstad
syver-en+usenet at online.no
Fri Apr 12 13:08:10 EDT 2002
Gustavo Niemeyer <niemeyer at conectiva.com> writes:
> > def Super(yourself):
> > if isinstance(yourself, type): # for classes
> > return super(yourself, yourself)
> > return super(yourself.__class__, yourself)
>
> I had the same idea a while ago. This can't be done. Think about what
> happens here:
>
> class A:
> def __init__(self):
> pass
> class B(A):
> def __init__(self):
> Super(self).__init__(self) # <-- problem
> class C(B):
> def __init__(self):
> Super(self).__init__(self)
>
> In this case, you'll get a loop, because self.__class__ is C, no
> matter where it is called.
Ahhh, I see. Shame, I guess it was too good to be true then :-)
--
Vennlig hilsen
Syver Enstad
More information about the Python-list
mailing list