“exit”
✈️: Use exit() or Ctrl-D (I.e. EOF) to exit
I mean if they can see that we type exit and show us this message, why could they not just start the exiting when we type exit?
Because exit might be a variable you use to determine if you should exit. exit() is a function that actually does the exiting.
It’s the difference between pointing at a jogger and saying “run” and actually running after them.
This is the code (Github link):
class Quitter(object): def __init__(self, name, eof): self.name = name self.eof = eof def __repr__(self): return 'Use %s() or %s to exit' % (self.name, self.eof) def __call__(self, code=None): # Shells like IDLE catch the SystemExit, but listen when their # stdin wrapper is closed. try: sys.stdin.close() except: pass raise SystemExit(code)
What happens is that the python repl calls
__repr__
automatically on each variable/statement that you type into the repl (except assignments e.g.x = 1
). But this basically only happens in the repl. So “executing” onlyexit
wouldn’t work in a python script as it is not calling__repr__
automatically, so better you learn how to do it right than using justexit
in your python scripts and scratching your head why it works in the repl but not in your code.
The Python REPL is fucking good.
No, it’s not: https://github.com/prompt-toolkit/ptpython.
https://github.com/prompt-toolkit/ptpython
the dot at the end of your link breaks it
On Sync it works fine. Moreover, it should work on other clients too. You better open a ticket.
That’s giving me a 404, captain
You can search it yourself. The PYPI package is ptpython.
import gravity; gravity = None
edit: of course there is an xkcd: https://xkcd.com/353/.
What’s the name of the Island, Java?
Snake island