470,644 Members | 1,232 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,644 developers. It's quick & easy.

Collecting Python's responses.

I'm looking for ways of creating annotated records of Python
interactive sessions, for documentation purposes. For example,
something like

# dir shows the contents of the namespace
dir() ['__builtins__', '__doc__', '__name__']
# Addition works too 1+2

3

However, I would like to automate the incorporation of Python's actual
output, so I would like to run a program which looks something like
this:
session(text('dir shows the contents of the namespace'),
code('dir()'),
text('Addition works too'),
code('1+2'))

which would somehow send the code to a Python process, collect the
response, and interleave the two with the annotation text to create
HTML output, or commented Python source code (or some other format for
which I provide a back end).

Does anything like this exitst? If not, any suggestions how best to go
about it. (The popen family seems unsuitable because of buffering
deadlocks, I'd rather not use telnetlib ...)

Jul 18 '05 #1
4 1089
Jacek Generowicz wrote:

[...]
Does anything like this exitst? If not, any suggestions how best to go
about it.


Would it be possible just to do it in the local process, using
http://docs.python.org/lib/module-code.html ?

Or if there's a reason not to do it locally, then do it through
sockets but still using that...

-Peter
Jul 18 '05 #2
You might be able to subclass code.InteractiveInterpreter to do this.
Jacek Generowicz <ja**************@cern.ch> wrote in message news:<ty*************@pcepsft001.cern.ch>...
I'm looking for ways of creating annotated records of Python
interactive sessions, for documentation purposes.

Jul 18 '05 #3
Peter Hansen <pe***@engcorp.com> writes:
Jacek Generowicz wrote:

[...]
Does anything like this exitst? If not, any suggestions how best to go
about it.
Would it be possible just to do it in the local process,


That's exactly what my prototype does.
http://docs.python.org/lib/module-code.html ?


Ah, this looks interesting. Thanks.

Jul 18 '05 #4
Jacek Generowicz wrote:
I'm looking for ways of creating annotated records of Python
interactive sessions, for documentation purposes. For example,
something like

# dir shows the contents of the namespace
>>> dir() ['__builtins__', '__doc__', '__name__']
# Addition works too >>> 1+2

3

However, I would like to automate the incorporation of Python's actual
output, so I would like to run a program which looks something like
this:


[snip]

This could be an easy addition to ipython (http://ipython.scipy.org). It
already has all the display hooks in place, and in fact the output handler is
user-accessible.

Cheers,

f
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

54 posts views Thread by Brandon J. Van Every | last post: by
8 posts views Thread by Chris Gray | last post: by
20 posts views Thread by Daniel Ehrenberg | last post: by
reply views Thread by Antal Rutz | last post: by
48 posts views Thread by northband | last post: by
4 posts views Thread by mlimber | last post: by
18 posts views Thread by Grant Edwards | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.