[IPython-dev] Multiple outputs per input line

Brian Granger ellisonbg at gmail.com
Mon Mar 14 01:32:32 EDT 2011


> On Sun, Mar 13, 2011 at 9:26 AM, Thomas Kluyver <takowl at 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.

Our model of output is that it is a continuous stream that can happen
at any moment in time and which can be completely uncorrelated with
particular input lines.  The history should reflect this reality.

>> 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?

If we are going to log output, we should log everything in stream format.

>> (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?

I think that would get quite difficult.  Mathematica's notion of
output is very specific and concrete (they basically trigger a
displayhook on every assignment).  Our notion of "output" now is very
dynamic - especially when you mix multiple frontends into the picture.

Brian

> f
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>



-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu
ellisonbg at gmail.com



More information about the IPython-dev mailing list