[IPython-User] Pretty print as default print function

Thomas Kluyver takowl@gmail....
Fri Nov 16 04:53:17 CST 2012

On 10 November 2012 08:34, Carl Smith <carl.input@gmail.com> wrote:

> Can you not redirect stdout to a method with something like...
> class StandardOut(object):
>     def __init__(self): pass
>     def write(self, string):
>         do_stuff()
> I'm not sure if that'll work. Just thinking out loud really.

I don't think this (overriding sys.stdout) will work for what Gökhan is
trying to do. Unlike displayhook(), which gets an object,
sys.stdout.write() only gets the string form, so you can't easily produce a
different representation.

For a Python class, you could monkeypatch __str__() to produce your
preferred representation, but ndarray is defined in compiled code, so
that's not an option.

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

More information about the IPython-User mailing list