Quantcast
Channel: Python – The musing of Philip Roche
Viewing all articles
Browse latest Browse all 11

Python command history

$
0
0

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

Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images