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

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Nov 23 21:16:10 EST 2011


On Wed, 23 Nov 2011 10:37:56 +0000, Tim Golden wrote:

> 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)

Doesn't work for me, at least not with Python 2.5 and 2.6 on Linux.

I don't suppose you are running a site-specific command history script in 
your startup.py file?


[steve at wow-wow ~]$ unset PYTHONSTARTUP
[steve at wow-wow ~]$ python
Python 2.5 (r25:51908, Nov  6 2007, 16:54:01)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print 42
42
>>>
[1]+  Stopped                 python
[steve at wow-wow ~]$ python
Python 2.5 (r25:51908, Nov  6 2007, 16:54:01)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>


You can't see it, but I'm hitting the up arrow on that last line, and 
nothing is happening except my console is flashing :)


-- 
Steven



More information about the Python-list mailing list