[IPython-User] output of multiple statements?

Zoltán Vörös zvoros@gmail....
Sun Jan 22 16:34:30 CST 2012


Greeting Thomas,

Thanks for the comments! I have but one question left.

On 01/22/2012 10:44 PM, Thomas Kluyver wrote:
> It's easy enough to display them all if we decide we want to, but I 
> don't think it's necessarily what we want. Lots of functions you 
> invoke for their side effects may return a value that you're not 
> interested in seeing (for instance, in Python 3, writing to a file 
> returns the number of bytes written). I think having one input cell to 
> one item of output keeps it clear what's going on. You can of course 
> use print to produce extra output.
I see your point, but calling print explicitly has slightly different 
behaviour. Here is an example:

def foo():
     bar = 'this should be displayed'
     return bar*10

Now, the output of

In [1]: foo()

is

Out[4]:

this should be displayedthis should be displayedthis should be displayedthis s
hould be displayedthis should be displayedthis should be displayedthis should
be displayedthis should be displayedthis should be displayedthis should be dis
played

(as is the output of
In [1]: foo()

	foo()
)

However, the output of

In [1]: print foo()

is
Out[5]: this should be displayedthis should be displayedthis should be displayedthis should be displayedthis should be displayedthis should be displayedthis should be displayedthis should be displayedthis should be displayedthis should be displayed


so the print statement does not respect the size constraints of the 
browser. As a matter of fact, it was
such a case that I had, and where I would have been glad to see the 
outputs of all instructions.
It could be hard to fix this, though.
Best,
Zoltán

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120122/856dbe9d/attachment.html 


More information about the IPython-User mailing list