can someone explain 'super' to me?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Dec 8 13:55:51 EST 2009


En Sat, 05 Dec 2009 07:27:54 -0300, Michael <michaelmossey at yahoo.com>  
escribió:

>> From the docs about the built-in function super:
>
> ----------------------------
> super( type[, object-or-type])
>
> Return the superclass of type. [...]

You won't get anywhere from the docs in this case, unfortunately. Start by  
reading these three articles by Michele Simionato:
http://www.artima.com/weblogs/viewpost.jsp?thread=236275
and also the famous "Python super() considered harmful":
http://fuhm.net/super-harmful/

> It seems like it can return either a class or an instance of a class.
> Like
> super( C, self)
> is like casting self as superclass C.

Not really - I hope you'll understand what that means after reading the  
above articles, feel free to ask again then.

> However if you omit the second argument entirely you get a class.

Those "unbound" super objects are rare; you probably won't need them.  
They're discussed in M.S. article, though.

-- 
Gabriel Genellina




More information about the Python-list mailing list