fork download
  1. class Ololo:
  2. def __init__(self):
  3. self.a = 'BOO!'
  4.  
  5. @classmethod
  6. def yay(cls):
  7. inst = cls.__new__(cls)
  8. inst.a = 'YAY!'
  9. return inst
  10.  
  11. def __str__(self):
  12. return self.a
  13.  
  14. a = Ololo()
  15. print(a)
  16. b = Ololo.yay()
  17. print(b)
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
BOO!
YAY!