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

Tim Golden mail at timgolden.me.uk
Thu Nov 24 03:51:35 EST 2011


On 24/11/2011 06:22, Chris Angelico wrote:
> On Thu, Nov 24, 2011 at 5:11 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info>  wrote:
>> One of us is confused, and I'm pretty sure it's you :)
>>
>> Tim went on to say "Obviously this only applies when an underlying cmd
>> session persists", which I understood as implying that he too is using
>> Linux where Ctrl-Z stops the process, but does not exit it.
>
> Entirely possible :) I blithely assumed from the fact that he said
> "dir" that it was Windows, but it goes to show what happens when you
> assume.

Ahem. Sorry for any confusion caused. The OP was asking about the
situation on Windows, and I was responding in that context. The
Ctrl-Z thing is what *exits* the interpreter on Windows (a la Ctrl-D
on Linux).

In short - on Windows, within one cmd shell you can open and exit
the interpreter as many times as you like and the Python command
history will be retained via the cmd shell's history mechanism,
and kept distinct from the history of other things you may type
into the cmd shell.

If you exit the cmd shell then that history is lost, and I'm not
aware of any mechanism for retaining it.

All this may or may not be of any use to the OP. I was responding
to this comment by Steven:

"The default interactive interpreter for Python doesn't have persistent
history, so if you exit the interpreter and restart it, your commands
are gone."


TJG




More information about the Python-list mailing list