super - is (should) it (be) a reserved word?
Rainer Deyke
root at rainerdeyke.com
Sat Oct 7 12:19:12 EDT 2000
"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:8rmu1e12bc1 at news1.newsguy.com...
> import new
>
> class WithSuper:
> def __init__(self, *args, **keywords):
> self.super=new.instance(self.__class__.__bases__[0],
self.__dict__)
> self.super.__init__(*args, **keywords)
>
> class A:
> def __init__(self):
> self.a=23
> def dotry(self):
> print self.a
>
> class B(A, WithSuper):
> def __init__(self):
> WithSuper.__init__(self)
> self.b=45
> def dotry(self):
> print self.b
> self.super.dotry()
Problem with this approach:
class C(B):
def __init__(self):
B.__init__(self)
C().dotry() # Infinite recursion! Yeah!
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list