Usage of Python 3 super()
Posted
by deamon
on Stack Overflow
See other posts from Stack Overflow
or by deamon
Published on 2010-05-05T09:23:11Z
Indexed on
2010/05/05
13:38 UTC
Read the original article
Hit count: 646
I wonder when to use what flavour of Python 3 super().
Help on class super in module builtins:
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)
Until now I've used super()
only without arguments and it worked as expected (by a Java developer).
Questions:
- What does "bound" mean in this context?
- What is the difference between bound and unbound super object?
- When to use
super(type, obj)
and whensuper(type, type2)
? - Would it be better to name the super class like in
Mother.__init__(...)
?
© Stack Overflow or respective owner