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)
これまで私はsuper()
引数なしでしか使用していませんでしたが、期待どおりに機能しました(Java開発者による)。
質問:
- この文脈で「バインドされた」とはどういう意味ですか?
- バインドされたスーパーオブジェクトとバインドされていないスーパーオブジェクトの違いは何ですか?
- いつ使用
super(type, obj)
するのsuper(type, type2)
か? - のようにスーパークラスに名前を付ける方がよいでしょう
Mother.__init__(...)
か?