<p>The only thing I can think of is to hack an ast transformation into %run, to turn print statements into calls to a function you've defined.</p>
<p>The good news is that a lot of scientific python packages now support python 3.</p>
<p>Thanks, <br>
Thomas</p>
<div class="gmail_quote">On Nov 10, 2012 1:10 AM, "Gökhan Sever" <<a href="mailto:gokhansever@gmail.com">gokhansever@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Thanks for the reply Thomas.</div><div> </div><div>I still use Python 2.7, along with all of the scientific Python stack. </div><div> </div><div>Do you think is there a simple way to modify IPython's "run" command so that output's pretty printed just like IPython shell?</div>
<div> </div><div> </div><div class="gmail_quote">On Fri, Nov 9, 2012 at 2:28 AM, Thomas Kluyver <span dir="ltr"><<a href="mailto:takowl@gmail.com" target="_blank">takowl@gmail.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<p>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.</p>
<p>Thomas</p>
<div class="gmail_quote"><div><div>On Nov 9, 2012 6:59 AM, "Gökhan Sever" <<a href="mailto:gokhansever@gmail.com" target="_blank">gokhansever@gmail.com</a>> wrote:<br type="attribution"></div></div>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div><div>
Hello,<div><br></div><div>I would like to be able print NumPy arrays matching the IDL's array print outout. For instance:</div><div><br></div><div><div>IDL> print, findgen(5)</div><div> 0.00000 1.00000 2.00000 3.00000 4.00000</div>
<div>IDL> print, dindgen(5)</div><div> 0.0000000 1.0000000 2.0000000 3.0000000 4.0000000</div></div><div> 0.0000000 1.0000000 2.0000000 3.0000000 4.0000000</div>
<div><br></div><div><br></div><div><div>I1 np.arange(5, dtype='float64')</div><div>O1 0.0000000 1.0000000 2.0000000 3.0000000 4.0000000</div></div><div><br></div><div>I2 np.arange(5, dtype='float32')</div>
<div><div>O2 0.00000 1.00000 2.00000 3.00000 4.00000</div></div><div><br></div><div>Ignoring O1 and O2 lines, outputs (formatting) are matching. I achieved this by defining some custom pprint formatters in the IPy config file.</div>
<div><br></div><div>However, this is only valid within IPython while just typing array names. For instance, running these lines revert the printing settings back to normal.</div><div><br></div><div>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?</div>
<div><br></div><div>If not, should I edit numpy/core/arrayprint.py and use a pythonrc file to achieve the effect?</div><div><br></div><div>I am also interested in custom printing other data types than nd.arrays.</div><div>
<br></div><div>Thanks.</div><div><br></div><div>-- </div><div>Gökhan<br>
</div>
<br></div></div>_______________________________________________<br>
IPython-User mailing list<br>
<a href="mailto:IPython-User@scipy.org" target="_blank">IPython-User@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
<br></blockquote></div>
<br>_______________________________________________<br>
IPython-User mailing list<br>
<a href="mailto:IPython-User@scipy.org" target="_blank">IPython-User@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Gökhan<br>
<br>_______________________________________________<br>
IPython-User mailing list<br>
<a href="mailto:IPython-User@scipy.org">IPython-User@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
<br></blockquote></div>