Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class First(object):
- def __init__(self, arg):
- self.arg = arg
- def my_arg(self):
- return self.arg
- class Second(First):
- def my_arg(self):
- return self.arg + 2
- class Third(Second):
- def my_arg(self):
- return super().my_arg() + 4
- el = Second(1)
- assert el.my_arg() == 3
- el.__class__ = Third
- assert el.my_arg() == 7
Advertisement
Add Comment
Please, Sign In to add comment