When can I use super(type)
? Not super(type,obj)
but super(type)
- with one argument.
From my understanding, super(x)
returns an "unbound" descriptor, that is, an object that knows how to get data, but has no idea where. If you assign super(x)
to a class attribute and then retrieve it, the descriptor machinery cares for proper binding:
class A(object):
def foo(self):
print 'parent'
class B(A):
def foo(self):
print 'child'
B.parent = super(B)
B().foo()
B().parent.foo()
See http://www.artima.com/weblogs/viewpost.jsp?thread=236278 for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With