Why do I have to specify my own class when using super(), and is there a way to get around it?

后端 未结 4 2057
暗喜
暗喜 2020-12-31 05:45

When using Python\'s super() to do method chaining, you have to explicitly specify your own class, for example:

class MyDecorator(Decorator):
           


        
4条回答
  •  再見小時候
    2020-12-31 06:28

    The BDFL agrees. See PEP 3135 - New Super for Python 3.0 (and Pep 367 - New Super for Python 2.6).

提交回复
热议问题