this post was submitted on 03 Jun 2025
491 points (99.0% liked)

Programmer Humor

23842 readers
2614 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 83 points 4 days ago (1 children)

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.

[–] [email protected] 42 points 4 days ago (1 children)

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.

[–] wise_pancake 18 points 4 days ago* (last edited 4 days ago) (1 children)

It’s not really much extra effort though

They just added so e text to the __repr__ method on the exit callable object

That’s much easier than figuring out if your running this interactively and trying to figure out if this is going to break stuff.

[–] [email protected] 1 points 4 days ago (2 children)

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

[–] [email protected] 5 points 3 days ago (1 children)

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 exit

also 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

[–] [email protected] 3 points 3 days ago

Good points. You're right, it does need solved at the shell level. Glad they did so.

[–] wise_pancake 1 points 3 days ago* (last edited 3 days ago)

The code isn’t high effort, it’s all the stuff you have to think about breaking

But generally I don’t think anyone prints exit in most contexts

Ps mad respect for doing that on your phone