Category Archives: iPython

Python command history

Obviously iPython is the bee’s kness when it comes to Python shells but if you don’t have iPython installed then getting command history can be a pain. Not any more 🙂

import readline; print '\n'.join([str(readline.get_history_item(i)) for i in range(readline.get_current_history_length())])

This will print all python commands run during that session.

Also as a gist

If you have iPython installed, it’s as simple as

%history