Collecting Python's responses.

J

Jacek Generowicz

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 ['__builtins__', '__doc__', '__name__']
# Addition works too 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 ...)
 
F

Fernando Perez

Jacek said:
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['__builtins__', '__doc__', '__name__']
# Addition works too3

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
 

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

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,053
Members
47,656
Latest member
rickwatson

Latest Threads

Top