News for hackers. Stuff that matters.
Re:Helping a Million Developers Exit Vim by Macha on Tuesday May 23, 2017 @02:05PM (#14403593)
So it actually doesn't, it's basically just a hack around the fact that the repl is basically:

    while True:
        print(str(eval(input())))
Case in point:

    >>> x = str(quit)
    >>> x
    'Use quit() or Ctrl-Z plus Return to exit'
I suppose you could implement quit.__str__ as sys.exit(0), if you really wanted to avoid this problem.
Re:Helping a Million Developers Exit Vim by thoth on Tuesday May 23, 2017 @02:31PM (#14403858)
Whatever logic currently used to print the 'Use quit() or Ctrl-Z plus Return to exit' message could also... quit the REPL in the first place, right?

I don't program Python much but do its users constantly type "quit" but not actually want to quit such that the REPL special cases this situation?

Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @03:54PM (#14404668)
> Whatever logic currently used to print the 'Use quit() or Ctrl-Z plus Return to exit' message could also... quit the REPL in the first place, right?

That one would probably be somewhat risky actually, that message is the "repr" of the quit object/function, displaying results at the repl invokes repr… but so does printing most containers, so e.g. `vars(__builtins__)` (to get a quick list of the builtins) would also quit the repl, which would be undesirable.

Re:Helping a Million Developers Exit Vim by wcoenen on Tuesday May 23, 2017 @04:47PM (#14405184)
There is no special logic behind it. It just prints the value of the variable with the name "quit", the same way it would print the value of the variable "foo" if you typed "foo".
Re:Helping a Million Developers Exit Vim by khedoros1 on Tuesday May 23, 2017 @05:16PM (#14405434)
The repl's basically supposed to help you write a program by matching the behavior of Python itself. What if I've got a variable called "quit" and I want to check its value?

The repl treats it specially because "quit", taken out of the context of the repl, makes sense as something to type in when trying to quit an unfamiliar program, not because actual Python programmers are likely to type it often.

Re:Helping a Million Developers Exit Vim by masklinn on Tuesday May 23, 2017 @02:11PM (#14403654)
> So it actually doesn't

It does, it just does not care.

> it's basically just a hack around the fact that the repl is basically:

I know what a REPL is. Here's an idea: it's not difficult to add an exit special case to the REPL.

> Case in point:

Case in point: the developers added a "help text" to tell users to go fuck themselves, knowing exactly what users wanted to do and refusing to do it. quit's repr didn't appear by magic, it was put there, knowingly, by people who understood exactly what they were doing.

Re:Helping a Million Developers Exit Vim by sbmassey on Tuesday May 23, 2017 @05:08PM (#14405367)
quit is not a piece of repl functionality, it is a python function that will exit the repl when called, with a string representation that gives that message. If I set quit = 1, or if I define my own quit() function, I don't want to have to be continually fighting the repl in order to inspect its value.
Re:Helping a Million Developers Exit Vim by monknomo on Tuesday May 23, 2017 @03:00PM (#14404147)
Humane programming is something I wish compiler and language builders would do more of
Re:Helping a Million Developers Exit Vim by marvin on Tuesday May 23, 2017 @05:54PM (#14405700)
Approximately 50% of the contributors in this thread argue actively against it, so I wouldn't hold my breath ;)
Re:Helping a Million Developers Exit Vim by monknomo on Tuesday May 23, 2017 @06:05PM (#14405781)
That was not lost on me. They're wrong, and kinda mean TBH, but someday someone will make a pretty good language, with a really helpful compiler/interpreter and will have the viral-fu to get it in use
Re:Helping a Million Developers Exit Vim by pishpash on Tuesday May 23, 2017 @04:09PM (#14404824)
It's insidiously more malevolent than that, considering how much productivity is wasted.