[IPython-User] Pretty print as default print function
Fri Nov 16 05:27:34 CST 2012
On 2012-11-16 10:53 AM, Thomas Kluyver wrote:
> On 10 November 2012 08:34, Carl Smith <email@example.com
> <mailto:firstname.lastname@example.org>> wrote:
> Can you not redirect stdout to a method with something like...
> class StandardOut(object):
> def __init__(self): pass
> def write(self, string):
> 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.
The array formatting code is pure Python and monkeypatchable:
More information about the IPython-User