How to auto register a class when it's defined

后端 未结 6 476
无人及你
无人及你 2020-12-04 19:23

I want to have an instance of class registered when the class is defined. Ideally the code below would do the trick.

registry = {}

def register( cls ):
            


        
6条回答
  •  自闭症患者
    2020-12-04 20:02

    Calling the Base class directly should work (instead of using super()):

      def __init__(self):
            Base.__init__(self)
    

提交回复
热议问题