By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

saving interpreter source?

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Garett wrote:
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
Jul 18 '05 #2

P: n/a
Peter Hansen wrote:
Garett wrote:
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


Also, take a look at the following. It tells you how to configure
your interactive sessions so that both (1) interactive history
will be saved to a file and (2) that history will be available in
subsequent interactive sessions.

Dave

--
http://www.rexx.com/~dkuhlman

Jul 18 '05 #3

P: n/a
Dave Kuhlman wrote:
Peter Hansen wrote:
Garett wrote:
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


Also, take a look at the following. It tells you how to configure
your interactive sessions so that both (1) interactive history
will be saved to a file and (2) that history will be available in
subsequent interactive sessions.


Oops. Forgot the link. Here it is:

http://docs.python.org/lib/readline-example.html

Dave

--
http://www.rexx.com/~dkuhlman
Jul 18 '05 #4

P: n/a
Garett wrote:
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.

--
Weather in Twenthe, Netherlands 22/04 10:25:
15.0°C Few clouds mostly cloudy wind 1.3 m/s SW (57 m above NAP)
--
Experiences with Asperger's Syndrome:
EN http://topjaklont.student.utwente.nl/english/
NL http://topjaklont.student.utwente.nl/

Jul 18 '05 #5

P: n/a
On Wed, 21 Apr 2004 10:36:48 -0600, Garett <as**@asdf.asdf> wrote:
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
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.