Python IDLE/Terminal return back after error
<p>When reading a book or just coding on terminal/IDLE it's common to make typo, forgot brace or comma etc. After I got error and all what I wrote before is lost.
Then I have to write down code again..
Is there any way/option to return back all what write before and just edit mistake and continue to code?</p>

<p>IDLE's Shell window is statement rather that line oriented.  One can edit any line of a statement before submitting it for execution.  After executing, one may recall any statement by either a) placing the cursor anywhere on the statement and hitting Enter, or b) using the history-next and history-prev actions.  On Windows, these are bound, by default, to Alt-p and Alt-p.  To check on your installation, Select Options => IDLE preferences on the menu.  In the dialog, select the Keys tab.  Under Custom Key Bindings, find the 'histor-xyz' actions in the alphabetical list.</p>

<p>For short, one-off scripts, I have a scratch file called tem.py.  Since I use it often, it is usually accessible via File => Recent files.</p>

python terminal edit python-idle undo