Python class inheritance: AttributeError: '[SubClass]' object has no attribute 'xxx'

后端 未结 5 1778
时光说笑
时光说笑 2020-12-10 00:51

I have the following base class and subclass:

class Event(object):
    def __init__(self, sr1=None, foobar=None):
        self.sr1 = sr1
        self.foobar          


        
5条回答
  •  孤街浪徒
    2020-12-10 01:35

    You need to call the __init__ method of the base class from the __init__ method of the inherited class.

    See here for how to do this.

提交回复
热议问题