Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A convenient feature of most Unix terminals is the fact that you can hit the up and down arrow keys to scroll through your command history to repeat old commands.

This feature also exists in the Python shell when run from the Unix terminal.

My problem is that if I'm debugging a Python program, I'll typically start from Unix and type python and then from mypython import *, then I'll start running and checking my functions. If I end up with an error at any point and I need to make modifications to the file, I have to exit() python and reenter in order to issue a new import command that uses the modified file. Usually I have typed several long and complicated commands that I would like to repeat so it would be great if the command history were maintained between sessions.

So I want to know if there is a way to merge the command history between Unix and Python, or alternatively a way to retain command history between Python sessions.

share|improve this question
Why don't you just press Ctrl-z to suspend the python session? Then edit your file and type fg to resume your python session. – Nifle Jan 24 '13 at 20:29
@Nifle The main issue is not exiting python to make edits, say in Emacs or something. The main issue is that because I've already issued the from abc import * command I can't release that import and issue a new from abc import * command that uses the modified version. – Ben Mordecai Jan 24 '13 at 20:37
Ahh, makes sense. – Nifle Jan 24 '13 at 20:38
Have you tried reload(modulename)? It won't work as well with the from something import * form as it does with import module and from import submodule though. – Celada Jan 25 '13 at 2:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.