[IPython-User] Pretty print as default print function

Thomas Kluyver takowl@gmail....
Fri Nov 9 03:28:27 CST 2012


In python 3, you can replace the builtin print function. I don't know of
any way to modify the behaviour of print statements in python 2.

Thomas
On Nov 9, 2012 6:59 AM, "Gökhan Sever" <gokhansever@gmail.com> wrote:

> Hello,
>
> I would like to be able print NumPy arrays matching the IDL's array print
> outout. For instance:
>
> IDL> print, findgen(5)
>       0.00000      1.00000      2.00000      3.00000      4.00000
> IDL> print, dindgen(5)
>        0.0000000       1.0000000       2.0000000       3.0000000
> 4.0000000
>        0.0000000       1.0000000       2.0000000       3.0000000
> 4.0000000
>
>
> I1 np.arange(5, dtype='float64')
> O1        0.0000000       1.0000000       2.0000000       3.0000000
> 4.0000000
>
> I2 np.arange(5, dtype='float32')
> O2       0.00000      1.00000      2.00000      3.00000      4.00000
>
> Ignoring O1 and O2 lines, outputs (formatting) are matching. I achieved
> this by defining some custom pprint formatters in the IPy config file.
>
> However, this is only valid within IPython while just typing array names.
> For instance, running these lines revert the printing settings back to
> normal.
>
> Is there a way to make this type of customized printing default for
> executing a file via Python? ie., can we replace python's print statement
> with pprint?
>
> If not, should I edit numpy/core/arrayprint.py and use a pythonrc file to
> achieve the effect?
>
> I am also interested in custom printing other data types than nd.arrays.
>
> Thanks.
>
> --
> Gökhan
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20121109/717e1909/attachment.html 


More information about the IPython-User mailing list