[IPython-dev] Multiple outputs per input line
Robert Kern
robert.kern at gmail.com
Mon Mar 14 12:39:16 EDT 2011
On 3/14/11 8:38 AM, Thomas Kluyver wrote:
> On 14 March 2011 10:59, Thomas Kluyver <takowl at gmail.com
> <mailto:takowl at gmail.com>> wrote:
>
> In fact, having thought about how I would do it, I'll code it up in a bit,
> and we can discuss a real system, rather than a hypothetical one.
>
>
> Right, that kept me occupied over lunch. Take a look at the code:
> https://github.com/takluyver/ipython/commit/498d9f5596113a9817b9a2fa4a14314c14bb7439
>
> Informal tests suggest that it's behaving as expected, but by all means pull the
> code and hunt for corner cases. If we're happy with this approach, I'll add some
> simple unit testing.
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:
In [1]: for i in range(3):
...: i
...:
Out[1]: 0
Out[1]: 1
Out[1]: 2
In [2]: Out[1]
Out[2]: 2
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.
--
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