{"id":9,"date":"2015-10-16T10:21:18","date_gmt":"2015-10-16T09:21:18","guid":{"rendered":"https:\/\/www.philroche.net\/?p=9"},"modified":"2015-10-16T10:21:18","modified_gmt":"2015-10-16T09:21:18","slug":"python-command-history","status":"publish","type":"post","link":"http:\/\/wp.philroche.net\/2015\/10\/16\/python-command-history\/","title":{"rendered":"Python command history"},"content":{"rendered":"
Obviously iPython<\/a> is the bee’s kness when it comes to Python shells but if you don’t have iPython<\/a> installed then getting command history can be a pain. Not any more \ud83d\ude42<\/p>\n This will print all python commands run during that session. <\/p>\nimport readline; print '\\n'.join([str(readline.get_history_item(i)) for i in range(readline.get_current_history_length())])<\/pre>\n