Devin Jeanpierre wrote:

> Oops, I just realized why such a claim might be made: the
> documentation probably wants to be able to say that any method can use
> super(). So that's why it claims that it isn't a method unless it's
> defined inside a class body.


You can use super anywhere, including outside of classes. The only thing you
can't do is use the Python 3 "super hack" which automatically fills in the
arguments to super if you don't supply them. That is compiler magic which
truly does require the function to be defined inside a class body. But you
can use super outside of classes:


py> class A(list):
...     pass
...
py> x = super(A)  # Unbound super object!
py> x.__get__(A).append
<method 'append' of 'list' objects>
py> a = A()
py> x.__get__(a).append
<built-in method append of A object at 0xb7b8beb4>



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to