2 ms·
Agreed, but in that case the tool shouldn't be trying to detect what I mean. Why look for 'exit' only so you can print 'no actually, it's exit() dummy'. If you'
by phs318u 3y ago
Agreed, but in that case the tool shouldn't be trying to detect what I mean. Why look for 'exit' only so you can print 'no actually, it's exit() dummy'. If you're parsing for it then just bloody do it! Otherwise I'll get a syntax error and realise that 'exit' isn't the right way to exit. And I'll do a quick search myself. But explicitly looking for and detecting my intention and then ignoring it is just dumb.
- slooonz 3y agoNothing is looking for exit. The REPL is calling repr(result) to show the result of the expression to the user. repr(exit) is the string "Use exit() or Ctrl-D (i.e. EOF) to exit". You _really_ don’t want repr(builtin) to have a side-effect like terminating the program. Stop being toxic and patronizing towards open-source developers out of ignorance.
- gizmo 3y agoipython has specifically implemented an Autocall that allows you to exit by typing exit, quit, exit() or quit(). https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.autocall.html#IPython.core.autocall.ExitAutocall https://ipython.readthedocs.io/en/stable/api/generated/IPyth... And repr(exit) also works fine: > In [1]: repr(exit) > Out[1]: '<IPython.core.autocall.ExitAutocall object at 0x102772770>' Maybe don't be so eager to accuse people of ignorance and toxicity.
- emmanueloga_ 3y agoPerhaps a variable `exit = True` or something was defined previously, you don't want to have the language or REPL handle a myriad of possible corner cases, that would be very brittle. But a printing warning or lint-like suggestion is ok and actually useful.
- gizmo 3y agoIt's not brittle. ipython has a special case for exit and quit. See my sibling comment. If you try to assign to exit you get a syntax error. Which is weird, but also fine in practice.