【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

猜你喜欢

转载自blog.csdn.net/chenhanxuan1999/article/details/83039949
今日推荐