On Sat, May 18, 2019 at 09:51:39PM +0530, Arup Rakshit wrote:

> Here, why super(Role, self).__init__(**kwargs) is used instead of 
> super().__init__(**kwargs) ? What that Role and self argument is 
> instructing the super() ?

The Role and self arguments are the owning class and current instance. 
They are always required, but in Python 2 you needed to provide them 
yourself, and it was error-prone. So in Python 3, the interpreter was 
modified to do the right thing when super is called with no arguments.

super() still accepts manual arguments, and in fact the signature is 
quite complex:

class super(object)
 |  super() -> same as super(__class__, <first argument>)
 |  super(type) -> unbound super object
 |  super(type, obj) -> bound super object; requires isinstance(obj, type)
 |  super(type, type2) -> bound super object; requires issubclass(type2, type)


but any use other than plain old super(Class, self) in Python 2 or 
super() in Python 3 is considered rather advanced.


-- 
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to