[IPython-dev] Re: Changes to Notebook Format

Fernando Perez Fernando.Perez at colorado.edu
Tue Aug 2 12:00:30 CDT 2005


Hans Meine wrote:
> On Monday 01 August 2005 21:51, Fernando Perez wrote:
> 
>>Fernando Perez wrote:

>>mmh, scratch that.  Upon thinking a bit more, it seems to me that since our
>>output proxies have to trap all write() calls, they should be able to
>>timestamp each one of them internally.  These timestamps should correspond
>>with the actuall call time, not with the results of output showing up on
>>the buffered output, so they are indeed enough to reconstruct the call
>>sequence.
> 
> 
> That's exactly the way we did it in our python shell for colored ouput (stderr 
> in red).

OK, good to know that someone has tested the idea and it does indeed work. 
Thanks.

>>The implementation would be still a bit delicate, as you want to tag output
>>to each stream as a separate kind, but multiple consecutive write() calls
>>to one kind of stream should not create new cells.  Instead, they should
>>continue writing to the currently open one, unless the other stream has had
>>a write() call made, time at which the code should open a new cell to
>>switch streams. It seems possible, but a fair bit of work.
> 
> 
> Indeed, since we had no "cells" (no notebook), we did not have that problem, 
> but that does not seem too hard, no?
> e.g. sth. along the lines of
> 
> class ErrorStream:
>    def write(s):
>       lastCell = {retrieve somehow}
>       if lastCell.type() == ErrorOutput:
>   lastCell.append(s)
>       else:
>          appendCell(ErrorOutputCell(s))

That should work, yes.  Nice and simple :)

Best,

f




More information about the IPython-dev mailing list