python shell that saves history of typed in commands that will persist between reboots

Tim Golden mail at timgolden.me.uk
Wed Nov 23 05:37:56 EST 2011


On 23/11/2011 10:29, Steven D'Aprano wrote:
> On Wed, 23 Nov 2011 11:23:19 +0200, Anssi Saari wrote:
>
>> goldtech<goldtech at worldpost.com>  writes:
>>
>>> Using Windows. Is there a python shell that has a history of typed in
>>> commands?
>>
>> Is there a shell that doesn't have history then? At least both the
>> vanilla shell and Idle both have basic history in Windows. IPython for
>> more fun.
>
> The default interactive interpreter for Python doesn't have persistent
> history, so if you exit the interpreter and restart it, your commands are
> gone.

Not quite

The interpreter inherits the command shell's history function:
Open a cmd window and then a Python session. Do some stuff.

Ctrl-Z to exit to the surrounding cmd window.
Do some random cmd stuff: dir, cd, etc.

Start a second Python session. up-arrow etc. will bring back
the previous Python session's commands (and not the ones you
entered in the surrounding shell)

Obviously this only applies when an underlying cmd session
persists -- if you simply start Python from Start > Run
twice the command history will not persist between sessions.

TJG



More information about the Python-list mailing list