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

Programmer Humor

23710 readers
2347 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
 
top 26 comments
sorted by: hot top controversial new old
[–] [email protected] 16 points 1 day ago (1 children)

Same energy as "Option -h not recognized; use --help for the list of options".

[–] [email protected] 16 points 1 day ago (1 children)

I can actually forgive that one since it's the fallback for any invalid argument.

[–] [email protected] 3 points 23 hours ago (1 children)

Not always, way too often you just get a variation of "invalid option, use --help to get a list of options"

How about you show me by default like most apps?

[–] [email protected] 3 points 18 hours ago (1 children)

They meant that you'd get the same message no matter what unrecognized option you use. So it's not like they added a specific check that if you type in -h they will give you the message, but instead you get the same message for any unrecognized option.

The thing in the OP only occurs if you type exit, so they specifically added that message to be shown when the interpreter clearly knows what you want, but you just didn't say it exactly right.

[–] [email protected] 1 points 17 hours ago (1 children)

I mean, if I didn't use a correct flag, my next command will probably include -h / --help

[–] [email protected] 1 points 9 hours ago

You aren't wrong, it wouldn't be bad for it to just print the help in that case, at least when running interactive.

For automation, printing the full help of a more complex command would completely trash logs.

[–] RapidCatLauncher 97 points 2 days ago (5 children)

That just gave me the idea that it would be fun to inspect exit a 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 its name and eof properties.

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 exit

Beauty!

[–] [email protected] 2 points 18 hours ago

Obviously they need to make exit's repr method raise a SystemExit

[–] [email protected] 1 points 18 hours ago

Does gtfo() then work as expected?

[–] [email protected] 1 points 20 hours ago

I don't think backticks are working with syntax highlighting (and it broke your codeblock)

[–] [email protected] 1 points 20 hours ago

This is art

[–] [email protected] 4 points 1 day ago

It never occurred me to inspect this, nice find.

[–] [email protected] 54 points 2 days ago

The dev thought "I know exactly what you meant, but I still insist you to do it my way".

[–] [email protected] 83 points 2 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 2 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 2 days ago* (last edited 2 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 2 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 1 day 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 1 day ago

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

[–] wise_pancake 1 points 2 days ago* (last edited 2 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

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

I have a vivid memory when I was in first grade and asked my teacher if I can use the bathroom, and I got his bullshit response. I was a first grader, so I sat my ass back down and held it. Fuck this horse shit mentality.

Fine, if you're an adult, it's juvenile, but at that point people should understand the difference. Doesn't mean I won't lambast a MFer for being a pedantic prick though.

[–] [email protected] 10 points 2 days ago* (last edited 2 days ago)

As an adult I'm asking nobody if I "may" use the bathroom. I might ask, "can I use YOUR bathroom" (notably not "may") or say "can you point me to the bathroom" because I am a human being with a right to access these facilities (Americans need not apply).

Teachers who feel the need to get one over on a child are pieces of shit. It teaches nobody anything except "adults are awful". Be nice to kids, you can fuck them up with something you don't think twice about.

[–] [email protected] 9 points 2 days ago
[–] [email protected] 4 points 2 days ago

People seriously don't use ^D to exit REPLs and shells? So much faster.