Guest User

Untitled

a guest
Dec 16th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. >>> class Test(object):
  2.  
  3. def __new__(cls):
  4. print ("new")
  5. return super(Test, cls).__new__(cls)
  6.  
  7. def __init__(self):
  8. print ("init")
  9.  
  10. >>> Test()
  11. new
  12. init
  13.  
  14. >>> class Test2(object):
  15. def __str__(self):
  16. return "I am test 2"
  17.  
  18. >>> class Test1(object):
  19. def __new__(cls):
  20. return Test2()
  21. >>> print(Test1())
  22. I am test 2
Add Comment
Please, Sign In to add comment