3 ms·
Well, the __repr__ method on the 'exit' object is getting called. So that method could actually call sys.exit() and cause repl to exit. But it would be very rud
by NoGravitas 11y ago
Well, the __repr__ method on the 'exit' object is getting called. So that method could actually call sys.exit() and cause repl to exit. But it would be very rude and strange behaviour for calling a __repr__ method to exit the interpreter, or, indeed, to do anything other than return a string representation of the object.
- sanderjd 11y agoPoint well made.
- fleitz 11y agoAnd quit calling exit isn't weird?
- deleted 11y ago[deleted]
- hyperpape 11y agoWhat someone more clever than me ought to do is write up a huge investigation of an obscure bug caused by exit.__repr__() calling sys.exit(), and then only at the end comment that it's not real, but could've been if Python went down this road.
- telotortium 11y agoWhy? quit and exit are imported exclusively at the REPL: https://docs.python.org/3/library/constants.html?highlight=exit#exit https://docs.python.org/3/library/constants.html?highlight=e.... Would it really be any worse than automatically assigning the result of the last expression to _?