Inheritance and Overriding __init__ in python

前端 未结 5 1653
春和景丽
春和景丽 2020-12-04 06:44

I was reading \'Dive Into Python\' and in the chapter on classes it gives this example:

class FileInfo(UserDict):
    \"store file metadata\"
    def __init_         


        
5条回答
  •  盖世英雄少女心
    2020-12-04 07:30

    Yes, you must call __init__ for each parent class. The same goes for functions, if you are overriding a function that exists in both parents.

提交回复
热议问题