Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. class SomeClass:
  2. def __init__(self):
  3. self.target = 'world'
  4.  
  5. def hello(self):
  6. print('hello {}'.format(self.target))
  7.  
  8.  
  9. some_instance = SomeClass()
  10.  
  11. class ProxyClass(some_instance.__class__):
  12. def hello(self):
  13. print('hi {}'.format(self.target))
  14.  
  15. some_instance.__class__ = ProxyClass
  16.  
  17. some_instance.hello()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement