How to get parent method as a function object?
Chris Liechti
cliechti at gmx.net
Wed Dec 11 18:19:55 EST 2002
David Eppstein <eppstein at ics.uci.edu> wrote in news:eppstein-
D8CBA2.13575911122002 at news.service.uci.edu:
> So my question is, suppose you don't want to call a shadowed method from
> a parent class, instead you want to create a first-arg-instantiated
> function object like you would get from self.foo?
...
> Or some other way of accessing
> this pre-instantiation machinery outside of a class?
>>> class A(object):
... def m(self): print "A"
...
>>> class B(A):
... def m(self): print "B"
...
>>> b=B()
>>> super(B, b).m
<bound method m.m of <__main__.B object at 0x0117BB18>>
>>> super(B, b).m()
A
>>> b.m()
B
but only for new style classes.
chris
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list