Python Finally Gets a Simple 'exit' Command

When working with the Python interpreter, I’ve always been slightly annoyed by Python’s insistence on proper function call syntax for the simplest of commands - namely, exit().

The Old Way #

For years, we’ve been forced to type those extra parentheses just to exit the interpreter:

>>> exit()  # The old way, with mandatory parentheses

If you forgot the parentheses, Python would helpfully remind you with “Use exit() or Ctrl-Z plus Return to exit”.

The New Way #

But rejoice! As of Python 3.13 (released October 7, 2024), we can finally just type:

>>> exit  # The new way, clean and simple

What Changed? #

The Python team, with significant contributions from the PyPy project developers, has introduced what they call “A better interactive interpreter.” This update includes direct support for REPL-specific commands like help, exit, and quit, without the need to call them as functions.

This change has been a long time coming. The discussion dates back to at least July 2021, as evidenced in the original GitHub issue. The main implementation details can be found in this issue.

Why This Matters #

While this might seem like a trivial change (it’s just two characters, after all), it’s a great example of Python’s commitment to user-friendliness. Most developers are used to shells where exit just works, and now Python’s REPL behaves more like what users expect.

Conclusion #

It’s refreshing to see Python continuing to improve its user experience, even with such seemingly small changes.