diff options
author | Pratik Karki <predatoramigo@gmail.com> | 2018-03-03 11:01:01 +0545 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-03 11:01:01 +0545 |
commit | 7177047aefc48433c80bc134870ec0bbdb9303bc (patch) | |
tree | 936bed8954f0dae7fa1068d2915895607cf68961 | |
parent | 631d1c1b475e0a007359776356bd9ed884ff7073 (diff) | |
parent | 50f93a94d4337b5a4f268d0832bf0fea55f55c37 (diff) |
Merge pull request #3073 from vegito2002/patch-1
Corrections on Python3 page
-rw-r--r-- | python3.html.markdown | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/python3.html.markdown b/python3.html.markdown index b0f04a02..019934cb 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -790,11 +790,11 @@ class Superhero(Human): # This calls the parent class constructor: super().__init__(name) - # overload the sing method + # override the sing method def sing(self): return 'Dun, dun, DUN!' - # add an additional class method + # add an additional instance method def boast(self): for power in self.superpowers: print("I wield the power of {pow}!".format(pow=power)) @@ -817,7 +817,7 @@ if __name__ == '__main__': # Calls parent method but uses its own class attribute print(sup.get_species()) # => Superhuman - # Calls overloaded method + # Calls overridden method print(sup.sing()) # => Dun, dun, DUN! # Calls method from Human @@ -872,7 +872,7 @@ class Batman(Superhero, Bat): def __init__(self, *args, **kwargs): # Typically to inherit attributes you have to call super: - #super(Batman, self).__init__(*args, **kwargs) + # super(Batman, self).__init__(*args, **kwargs) # However we are dealing with multiple inheritance here, and super() # only works with the next base class in the MRO list. # So instead we explicitly call __init__ for all ancestors. @@ -901,7 +901,7 @@ if __name__ == '__main__': # Calls parent method but uses its own class attribute print(sup.get_species()) # => Superhuman - # Calls overloaded method + # Calls overridden method print(sup.sing()) # => nan nan nan nan nan batman! # Calls method from Human, because inheritance order matters |