I find it somewhat frustrating that we periodically spend so much time and effort arguing about this, when there are no fewer than four trivially easy ways to exit the Python REPL:
and yet we cannot get any traction on providing even one simple way to clear the REPL. But I digress.
How far can a beginner get in Python without learning that
-
functions must be called with brackets (parentheses); and
-
the function name alone always refers to the object itself, it does not call the function?
This is not a rhetorical question. Surely this is something that people have to learn in the first twenty minutes of using Python.
Why is it “unreasonable” to call the quit function with parens, but not everything else? If it is unreasonable for quit
to need parens, then it is also unreasonable for help
, and random
, and len
and all the other functions.
IPython allows paren-free function calls too. As do other languages like Ruby. Of course, paren-less function calls cause its own issues.
If “IPython does it” is the gold standard for good UI, then the obvious question is why not just use IPython? Or if that is unacceptable, for some reason, does that mean that we ought to duplicate IPython’s magics? For example, if the Python REPL is a shell, and is expected to behave like a shell, then it must be “unacceptable” to need two lines and parentheses (and quotation marks!) to change the working directory:
import os
os.chwd('some/location')
IPython allows cd some/location
just like it allows quit
to quit.
Again, not a rhetorical question: how far do we go? IPython is an amazingly rich and powerful shell. How far towards duplicating the functionality of their magics system should we go? To me, it doesn’t seem reasonable to spend time and effort to specially handle only exit
and quit
as magic shell commands when there are so many other useful commands we could have.
Commands which are not just useful for beginners, but could be useful for experienced developers as well.
If we’re going to do this, and complicate the Python reference implementation with a new concept of “magical commands which have an immediate effect in the REPL” (as opposed to ordinary functions which need to be called with parens) then let’s not unnecessarily and artifically limit it to the trivial and boring quit/exit.