[IPython-user] printing lots of stuff to the screen

Walter Dörwald walter@livinglogic...
Fri May 25 04:14:24 CDT 2007


Stefan van der Walt wrote:
> On Thu, May 24, 2007 at 11:20:44PM -0600, Fernando Perez wrote:
>> On 5/24/07, Jerry McRae <qrs0xyc02@sneakemail.com> wrote:
>>> I believe it is a property of the shell, not IPython.  You didn't say what
>>> OS you are using.
>> Yup.  Ryan is, I think, on Windows, so your advice is spot on.  Under
>> linux, I use KDE's konsole, which has a similar option for setting the
>> size of the scrollback buffer.  Most terminal emulators offer such an
>> option somewhere, but it's not something that IPython, being
>> line-oriented and all, has any control over as of this time.
> 
> This sounds like a job for ipipe.  Attached is a patch for a new
> command called "icap", that captures any printed output of a given
> command.  For example
> 
> from ipipe import icap
> def foo(n):
>     for i in range(n):
>         print "We have %s results." % str(i+1)
> 
> icap("foo(100)")
> 
> which yields a browsable
> 
>  ibrowse #0: icap('foo(100)')
>   # |_                  |
>   0 |We have 1 results..|
>   1 |We have 2 results..|
>   2 |We have 3 results..|
>   3 |We have 4 results..|
>   4 |We have 5 results..|
>   5 |We have 6 results..|
> 
> etc.
> 
> This is just a proof of concept.  I don't know the internals of ipipe
> or ipython well, so there may be better ways to implement it.

This looks good to me.

However it has the problem, that the code must run to completion before
any output happens.

Servus,
   Walter


More information about the IPython-user mailing list