Which of the 4 ways to call super() in Python 3 to use?

后端 未结 2 1206
栀梦
栀梦 2020-12-05 14:17

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_         


        
2条回答
  •  半阙折子戏
    2020-12-05 15:12

    A quick note, the new usage of super is outlined in PEP3135 New Super which was implemented in python 3.0. Of particular relevance;

    super().foo(1, 2)
    

    to replace the old:

    super(Foo, self).foo(1, 2)
    

提交回复
热议问题