1. 程式人生 > >【Python3】兩種不同的繼承方式The two different inheritance method when using python3

【Python3】兩種不同的繼承方式The two different inheritance method when using python3

During the review of python classes, I found out that i missed the different situation of inheritance in python

The first type and the second type:

      Student.__init__(self,name,age)
        # super().__init__(name, age)

The first line shows that way invented in Python2

the second line began with # shows the way in Python3

So Python3 is better in simplifing the grammer, we can find that it need one less parameters

Actually , since python2.x we can use the form like super(Class, self).func() to use the method of super classes, but in python3,we can just use super().func to use the method of the super class