473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

saving interpreter source?

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
5 1557
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: a9605473 | last post by:
A simple question. Is it possible in the python (or ipython) interpreter to review the source code of a self defined function? Thanks Erwin
16
by: Neil Benn | last post by:
Hello, I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python...
12
by: Anon | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all I am a beginner teaching myself python, and I am enjoying it immensely :) As a language it is great, I real treat to study, I actually...
5
by: Leo | last post by:
Why is it not possible to get the frame from the interpreter using the inspect library? IOW, why does this code: >>> from inspect import * >>> stack() produce:
6
by: gr | last post by:
hi.. I must implement an interpreter in C programming language that will get the source code of a program in text file format and execute it. but i don't know C language enough to write this...
5
by: Joel | last post by:
In the course of my project, I must include some custom logic and would like to integrate a small script language in my application for that purpose. In C++, I used the LUA script language and I...
10
by: Janto Dreijer | last post by:
I have been having problems with the Python 2.4 and 2.5 interpreters on both Linux and Windows crashing on me. Unfortunately it's rather complex code and difficult to pin down the source. So...
40
by: castironpi | last post by:
I'm curious about some of the details of the internals of the Python interpreter: I understand C from a hardware perspective. x= y+ 1; Move value from place y into a register Add 1 to the...
0
by: Robert Kern | last post by:
Ognjen Bezanov wrote: Mostly. It is worth noting, though, that the Python bytecode is at a higher level than Java bytecode. You can run other languages on top of the JVM using Java bytecode...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.