Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. exit

exit

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
24 Posts 18 Posters 2 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R [email protected]

    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!

    S This user is from outside of this forum
    S This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #21

    Does gtfo() then work as expected?

    1 Reply Last reply
    0
    • S [email protected]

      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.

      rikudou@lemmings.worldR This user is from outside of this forum
      rikudou@lemmings.worldR This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #22

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

      S 1 Reply Last reply
      0
      • rikudou@lemmings.worldR [email protected]

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

        S This user is from outside of this forum
        S This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #23

        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.

        1 Reply Last reply
        0
        • somethingburger@jlai.luS [email protected]

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

          D This user is from outside of this forum
          D This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #24

          Or more subtly, when the command uses BSD (nowadays Go) style single-dash args, so it wants -help and not --help.

          1 Reply Last reply
          1
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups