That just gave me the idea that it would be fun to inspect
exita little.Which led me down this path:
>>> repr(exit) 'Use exit() or Ctrl-Z plus Return to exit' >>> dir(exit) [(...), 'eof', 'name'] >>> exit.eof, exit.name ('Ctrl-Z plus Return', 'exit')Okay, cool, the “Use exit() etc.” blurb appears because it’s the function’s
repr, and the string is assembled from itsnameandeofproperties.Now let’s try to make our own:
>>> exit.__class__ <class '_sitebuiltins.Quitter'> >>> gtfo = exit.__class__() TypeError: Quitter.__init__() missing 2 required positional arguments: 'name' and 'eof'Oh Python, you shouldn’t have.
>>> gtfo = exit.__class__("a big puff of smoke", "a sneaky skedaddle") >>> gtfo Use a big puff of smoke() or a sneaky skedaddle to exitBeauty!
It never occurred me to inspect this, nice find.
Obviously they need to make
exit’s repr method raise aSystemExit
The era of pedantry is finally over:
Direct support for REPL-specific commands like help, exit, and quit, without the need to call them as functions.
FINALLY! This has always annoyed me. If you’re gonna go through all the trouble of identifying that I want to exit, just DO it.
It’s not really much extra effort though
They just added so e text to the
__repr__method on theexitcallable objectThat’s much easier than figuring out if your running this interactively and trying to figure out if this is going to break stuff.
Lemme golf that
~ $ python Python 3.12.10 (main, Apr 9 2025, 18:13:11) [Clang 18.0.3 (https://android.googlesource.com/toolchain/llvm-project d8003a456 on linux Type "help", "copyright", "credits" or "license" for more information. >>> class x: ... def __repr__(s): ... exit(0) ... >>> xit = x() >>> xit ~ $Not that hard
repr is generally assumed to be side effect free and cheap to run, so things like debuggers tend to show repr of things in scope, including possibly
exitalso then it behaves differently between repl and script, since repr never gets run. to do it properly it has to be a new repl keyword I imagine, but I still don’t know if I’m sold on the idea
Good points. You’re right, it does need solved at the shell level. Glad they did so.
The dev thought “I know exactly what you meant, but I still insist you to do it my way”.
May I exit
Same energy as “Option
-hnot recognized; use--helpfor the list of options”.I can actually forgive that one since it’s the fallback for any invalid argument.






