When can I use super(type)
? Not super(type,obj)
but super(type)
- with one argument.
Asked
Active
Viewed 548 times
5
![](../../users/profiles/1332509.webp)
Ella Sharakanski
- 2,371
- 2
- 22
- 43
-
4Potentially interesting: https://mail.python.org/pipermail/python-3000/2007-September/010181.html (and Guido's response: https://mail.python.org/pipermail/python-3000/2007-September/010182.html) (these are from 2007 though). I also found [this](http://www.phyast.pitt.edu/~micheles/python/super.pdf), which was a bit confusing, at least to me, but might help. – Michael0x2a Nov 08 '13 at 07:08
1 Answers
2
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.
![](../../users/profiles/989121.webp)
georg
- 195,833
- 46
- 263
- 351