[IPython-dev] Multiple outputs per input line

Fernando Perez fperez.net@gmail....
Sun Mar 13 15:56:00 CDT 2011


On Sun, Mar 13, 2011 at 9:26 AM, Thomas Kluyver <takowl@gmail.com> wrote:
> I realised that it's possible to get multiple outputs from a single input
> line. Most trivially, you can do "for a in range(5): a", to produce 5
> outputs. At present, this crashes my sqlite-history branch if output logging
> is enabled, because it expects each output item to have a unique session and
> line number. In fact, the session output history doesn't really expect it
> either: it only stores the last result.
>
> It should be simple enough to catch the error in writing to the database,
> and only store the first result, or to use an SQL update statement so we
> only store the last result. Is that good enough for what I think is a fairly
> unusual case? Or do we want to work out a way of storing all the outputs
> from a command? Robert, logging output to the database was your suggestion,
> so perhaps you've got an opinion?
>
> (Of course, I can relax the restriction that session and line number must
> together be unique, but then getting useful information from the database
> becomes trickier.)

One thing we could do (that's what mathematica uses) is to simply
increase the counter every time an *output* is produced.   The logic
does get a little more complex, but it lets us retain uniqueness
throughout.  What do you think?

f


More information about the IPython-dev mailing list