[IPython-dev] Multiple outputs per input line

Robert Kern robert.kern@gmail....
Mon Mar 14 12:22:49 CDT 2011


On 3/14/11 12:04 PM, Thomas Kluyver wrote:
> [Apologies, meant to post this to list. Thanks, Robert, for pointing it out]
>
> On 14 March 2011 16:53, Thomas Kluyver <takowl@gmail.com
> <mailto:takowl@gmail.com>> wrote:
>
>     On 14 March 2011 16:39, Robert Kern <robert.kern@gmail.com
>     <mailto:robert.kern@gmail.com>> wrote:
>
>         I really don't think we want the Out[] variable to have lists of things.
>         That's
>         really annoying for the most common case and would break long-standing
>         usage.
>         Having multiple displayhook calls is almost always an accident (e.g.
>         usually you
>         make a function call for its side effects even if it returns something not
>         None), not an intentional act. I think the current behavior is perfectly
>         fine:
>
>
>     At present, the Out variable in the user namespace is the same object as the
>     stored output history from the current session. I think the best way is if I
>     separate these.
>
>         That said, for the recording of displayhook outputs in *history*, we may
>         as well
>         record all of the the things sent to the displayhook. In the SQLite
>         history, you
>         can do this by just using a dummy autoincrementing primary key for the
>         table and
>         letting the (session, line) columns be non-unique.
>
>
>     I tried this, but it would need additional logic in Python to display the
>     inputs and outputs in the right sequence. I prefer the system I've written,
>     where (session, line) is unique, and the outputs for each command are
>     serialised as JSON. Inputs and outputs are conveniently paired by SQL JOIN,
>     and it's trivial to display them correctly.

You would just ORDER BY the autoincrementing primary key.

But anyways, as Brian points out, we did decide some time ago that exactly one 
output should go to the displayhook, and the current behavior is probably a 
regression. For the SQLite history, just use the last one.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



More information about the IPython-dev mailing list