Dump interpreter history?

Dan Mahoney catdude at gmail.com
Fri Mar 25 21:12:23 EDT 2011


Yeah, sorry about that. The square brackets were supposed to indicate that
filename is an optional argument. If not supplied, defaults to .history.

Dan Mahoney
Catdude at gmail.com

Sent from my Android phone

On Mar 25, 2011 6:57 PM, "Tim Chase" <python.list at tim.thechases.com> wrote:

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110325/06b90372/attachment.html>


More information about the Python-list mailing list