2 ms·
Consider that there is zero reason not to print that line, and exit anyway.
by mrguyorama 4y ago
Consider that there is zero reason not to print that line, and exit anyway.
- thaumasiotes 4y agoThat's quite far from the truth. That's like saying that, if you read a textbook, there is zero reason to do any of the exercises. And from the implementation perspective, the python shell is trying to run a simple loop: 1. Read a line of python code. 2. Evaluate the code. 3. Print the result. Defining `exit` as the name of a string slots into that loop seamlessly. Defining it as a special keyword that is recognized by the shell, despite the fact that it has no special meaning to python, means you're no longer just reading python code; now you have to implement a separate parser solely for the purpose of handling this command.