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 itsname
andeof
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!
Does gtfo() then work as expected?
Yup
Nice!
It never occurred me to inspect this, nice find.
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.
The dev thought “I know exactly what you meant, but I still insist you to do it my way”.
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.
What other lessons did you refuse to learn in school?
Too many to count, but I learned this lesson. I just struggled with nuance in gramer as a fucking 1st grader.
May I exit
People seriously don’t use ^D to exit REPLs and shells? So much faster.