• Deconceptualist@lemm.ee
    link
    fedilink
    English
    arrow-up
    51
    arrow-down
    1
    ·
    4 months ago

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

    • dormedas@lemmy.dormedas.com
      link
      fedilink
      arrow-up
      44
      arrow-down
      2
      ·
      4 months ago

      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@lemmy.ca
        link
        fedilink
        arrow-up
        18
        ·
        edit-2
        4 months ago

        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.

        • scott@lemmy.org
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          1
          ·
          4 months ago

          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

          • brian@programming.dev
            link
            fedilink
            arrow-up
            4
            ·
            4 months ago

            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

            • scott@lemmy.org
              link
              fedilink
              English
              arrow-up
              3
              ·
              4 months ago

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

  • RapidCatLauncher@lemmy.ca
    link
    fedilink
    English
    arrow-up
    92
    ·
    4 months ago

    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!

  • BassTurd@lemmy.world
    link
    fedilink
    arrow-up
    18
    arrow-down
    2
    ·
    4 months ago

    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.

    • ProgrammingSocks@pawb.social
      link
      fedilink
      arrow-up
      12
      arrow-down
      2
      ·
      edit-2
      4 months 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.

      • BassTurd@lemmy.world
        link
        fedilink
        arrow-up
        6
        arrow-down
        3
        ·
        4 months ago

        Too many to count, but I learned this lesson. I just struggled with nuance in gramer as a fucking 1st grader.