{"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

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

This will print all python commands run during that session. <\/p>\n

Also as a gist<\/a><\/p>\n

If you have iPython<\/a> installed, it’s as simple as<\/p>\n

%history<\/pre>\n","protected":false},"excerpt":{"rendered":"

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 \ud83d\ude42 This will print all python commands run during that session. Also as a gist If you have iPython installed, it’s as simple as<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,11],"tags":[],"_links":{"self":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/posts\/9"}],"collection":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":0,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}