I find the following often happens to me:
- I am using Python in an interactive terminal session
- I accidentally type something with unbalanced parentheses
- Python gives me a
...prompt, expecting me to enter another line of code
- In an attempt to get back to the Python command prompt, I instinctively type
ctrl-D(end of transmission character)
- Instead of exiting back to the
>>>prompt, the Python process quits immediately, losing all the data from my interactive session
I would like this to not happen any more. Therefore my questions are:
Is there a way to prevent Python from quitting when
This might be wishful thinking, but is there any way I can make
ctrl-Dtake me back to the Python prompt as I keep expecting it to do?
I use Python 3.6 installed with MacPorts on a Mac, but I guess this is a fairly platform-independent question. I believe this installation uses the Gnu Readline library for user interaction in case that's relevant.