[IPython-dev] Re: Changes to Notebook Format

Fernando Perez Fernando.Perez at colorado.edu
Mon Aug 1 15:41:12 EDT 2005

Hans Meine wrote:
> On Wednesday 27 July 2005 07:44, Fernando Perez wrote:
>>>As for having stdout cells interleaved with other types of output cells,
>>>I think that's going to be pretty hard. You'd have to collect the output
>>>from each statement separately. I'm of the opinion that you should just
>>>collect one each of stdout and stderr.
> I disagree.  In my opinion, I want to preserve the order of interleaving 
> stdout/stderr outputs.  E.g.
>   for i in range(10):
>      myFunc(filenames[i])
> Now let myFunc output either "File processed fine." to stdout or "Error 
> processing file" to stderr.  (Admitted, the messages suck. ;-) )
> I would like to know exactly which i's failed.

Oh, I don't disagree with you that it would be _nice_ to have that 
interleaving.  The problem is _how_ to do it.  On the implementation end of 
things (where desires have to become reality), you have an object which can 
track each of the output streams (stdout/err), and that's about it.  Those 
animals are buffered to begin with, so knowing in a reliable way when data 
came into each is not really possible, I think even for a plain shell.

I seem to recall that even at the shell, quite often stdout and stderr come 
out in seemingly random interleaving order, depending on the (in practice 
random) details of buffer fill times.

So I'm not really sure how this could be done in general.  One possible 
conveninence feature we could add would be auto-timestamping.  Since we have 
to trap stdout and reroute it to the gui, we could offer the possibility of 
prepending each write() call with a timestamp.  This would be off by default, 
of course, but it could be useful in many circumstances.

If I'm missing some obvious solution to the interleaving problem, feel free to 
point it out.



More information about the IPython-dev mailing list