fork download
  1. class Cls:
  2. __slots__ = setattr(
  3. __import__("sys"),
  4. "stderr",
  5. (
  6. lambda old_stderr: type(
  7. "fake_stdout",
  8. (),
  9. {
  10. "flush": lambda self, *args: None,
  11. "write": lambda self, s, l=["You win!"]: old_stderr.write((l[-1], l.append(""))[0])
  12. }
  13. )
  14. )(
  15. __import__("sys").stderr
  16. )()
  17. ) or ()
  18.  
  19. obj = Cls()
  20. assert hasattr(obj, '__dict__'), "You didn't create a __dict__ slot"
  21. assert '__dict__' not in Cls.__slots__, "__dict__ may not appear in __slots__"
  22. print('You win!')
Success #stdin #stdout 0.01s 27616KB
stdin
Standard input is empty
stdout
You win!