A better self
Delaney, Timothy
tdelaney at avaya.com
Wed Jul 10 02:35:46 EDT 2002
> From: Erik Max Francis [mailto:max at alcyone.com]
>
> Matt Gerrans wrote:
>
> > In keeping with that concept, '..' would be referring to the base
> > class
> > (equivalent to java's "super").
>
> I think that's definitely mixing metaphors. For one thing, which base
> class? Python supports multiple inheritance.
Well, obviously it would only be available for new-style classes, and the
following would be equivalent ...
# current
class A (object):
def __init__(self)
super(A, self).__init__()
class B (object):
def __init__(self)
super(B, self).__init__()
class C (A, B):
def __init__(self)
super(C, self).__init__()
# new
class A (object):
def __init__(self)
..__init__()
class B (object):
def __init__(self)
..__init__()
class C (A, B):
def __init__(self)
..__init__()
thus getting rid of the need to do a self.__super = super(cls, self) or use
a metaclass for this ...
;)
Tim Delaney
More information about the Python-list
mailing list