fork download
  1. class A:
  2. def __init__(self):
  3. self.checked = False
  4.  
  5. def __bool__(self):
  6. if self.checked:
  7. return False
  8. else:
  9. self.checked = True
  10. return True
  11.  
  12. a = A()
  13.  
  14. while a:
  15. print('hello, world!')
Success #stdin #stdout 0.03s 9440KB
stdin
Standard input is empty
stdout
hello, world!