X
X
xillion2016-11-30 11:03:30
Python
xillion, 2016-11-30 11:03:30

How to initialize a variable in a child class?

class Event(object):
    def __init__(self, **kwargs):
        self.time = kwargs['time']
        self.severity = kwargs['severity']
        self.type = kwargs['type']
        self.uid = kwargs['uid']
        self.files = kwargs['files']


class MassStorageEvent(Event):
    def __int__(self,  **kwargs):
        self.device = kwargs['device']
        super(MassStorageEvent, self).__init__(**kwargs)


def main():

    firstEvent = MassStorageEvent(  time=15654687654.0,
                                    severity=3,
                                    type=1,
                                    uid=222,
                                    files='test.txt',
                                    device='ddf29347983')

    print('f')


if __name__ == '__main__':
    main()

I run the code above in the debugger, look at the firstEvent object and what do I see!? The device parameter is missing. What am I doing wrong? What to read, where to dig?
2cde56afa68c4bf6b45f06f2a93dbad4.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-11-30
@xillion

You have a typo in the MassStorageEvent constructor, missing the letter i .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question