[IPython-dev] Re: Changes to Notebook Format
tsanko at gmail.com
Tue Jul 26 07:50:44 CDT 2005
I found other problems with the current format. It is entirely possible
that a single input has several outputs, and prints to stdout and/or
stderr several times. Take for examlpe the following code.
In : if True:
...: print 'foo'
...: print 'bar'
To fix that we should allow several elements of types <output>, <stdout>
and <stderr> to be included in a cell. Also we want to keep the order in
which they were produced. I can see two ways to do this.
One way is to add an 'order' attribute to all the <output>, <stdout> and
<stderr> elements in the cell. Also in the <ipython-block> element all
the <ipython-output>, <ipython-stdout> and <ipython-stderr> elements
should have this attribute. Then we won't need separate tags in
<ipython-block> for all types of output, because the 'number' and
'order' attributes will be enough to decide which output element should
be displayed at the given position.
Another way is to use the order in which the elements in the cell are
written. We can state that the first one or two elements must be of type
<input> and <special-input>. The elements after them will be of types
<output>, <stdout>, <stderr>, <figure>, etc. and the order in which they
were produced by the input corresponds to the order in which they are
written in the cell. Then in <ipython-block> we can get rid of all the
different tags and replace them with tags like <element number='1'
cellnumber='2'/> which will point to the second element in the first
cell in the log.
Right now, I'm not really sure which one is better. The second way will
probably be faster to run, because I will be able to work with a cell
like a list and not use the find() method or XPath to retrieve elements.
What do you think?
More information about the IPython-dev