Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo(object):
- def __init__(self):
- pass
- class Bar(Foo):
- def __init__(self):
- super().__init__()
- Bar()
- class Foo(object):
- def __init__(self):
- pass
- class Bar(Foo):
- def __init__(self):
- super(Bar, self).__init__()
- Bar()
- In 2.7 use this [ super(baseclass, self).__init__() ]
- class Bird(object):
- def __init__(self):
- print("Bird")
- def whatIsThis(self):
- print("This is bird which can not swim")
- class Animal(Bird):
- def __init__(self):
- super(Bird,self).__init__()
- print("Animal")
- def whatIsThis(self):
- print("THis is animal which can swim")
- a1 = Animal()
- a1.whatIsThis()
- > In 3.0 or more use this [ super().__init__()]
- class Bird(object):
- def __init__(self):
- print("Bird")
- def whatIsThis(self):
- print("This is bird which can not swim")
- class Animal(Bird):
- def __init__(self):
- super().__init__()
- print("Animal")
- def whatIsThis(self):
- print("THis is animal which can swim")
- a1 = Animal()
- a1.whatIsThis()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement