Dump interpreter history?
Tim Chase
python.list at tim.thechases.com
Fri Mar 25 19:57:05 EDT 2011
On 03/25/2011 04:40 PM, Daniel Mahoney wrote:
> On Fri, 25 Mar 2011 17:03:55 -0400, Ken D'Ambrosio wrote:
>
>> Hey, all. A co-worker asked me a question, and I've got no idea how (or
>> if) it can be done. Bottom line: he'd like to save off the text from an
>> interpreter session, his thinking being that you've already tried to get
>> what you want, and now you just need to gussy it up in an editor.
>
> import readline
> readline.write_history_file([filename])
Just to clarify (I thought Daniel's answer was so easy it must
have misinterpreted the OP's request), that's a single string as
a filename, not a list containing a filename. I tried
filename = 'output.txt'
import readline
readline.write_history_file([filename])
and got a traceback about the expected parameter type. For
clarity, it should have been
readline.write_history_file(filename)
or
readline.write_history_file('output.txt')
But otherwise, Daniel's given a dead-easy solution.
-tkc
More information about the Python-list
mailing list