saving interpreter source?

G

Garett

Hello, I would like to be able to save source typed into the interpreter
to a file. Kind of like marshal, but I would like to have the file contain
the source so I can edit it later. Something like inspect.getsource() but
for source typed into the interpreter, not imported from a module. Is this
possible? Any ideas are greatly appreciated. -Garett
 
P

Peter Hansen

Garett said:
Hello, I would like to be able to save source typed into the interpreter
to a file. Kind of like marshal, but I would like to have the file contain
the source so I can edit it later. Something like inspect.getsource() but
for source typed into the interpreter, not imported from a module. Is this
possible? Any ideas are greatly appreciated. -Garett

Last time I used it, Chris Gonnerman's readline replacement kept a
history by default:

http://newcenturycomputers.net/projects/readline.html

-Peter
 
G

Gerrit

Garett said:
Hello, I would like to be able to save source typed into the interpreter
to a file. Kind of like marshal, but I would like to have the file contain
the source so I can edit it later. Something like inspect.getsource() but
for source typed into the interpreter, not imported from a module. Is this
possible? Any ideas are greatly appreciated. -Garett

Skip has once written something like that:

http://manatee.mojam.com/~skip/python/save_session.py

It won't work on Windows, however.

Gerrit.
 
D

Daniel 'Dang' Griffith

Hello, I would like to be able to save source typed into the interpreter
to a file. Kind of like marshal, but I would like to have the file contain
the source so I can edit it later. Something like inspect.getsource() but
for source typed into the interpreter, not imported from a module. Is this
possible? Any ideas are greatly appreciated. -Garett

Look into IPython. It's "An enhanced Interactive Python shell", and
includes a "save" command, where you can even specify which lines you
want saved. http://ipython.scipy.org/
--dang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top