[Numpy-discussion] Porting strategy for py3k

Ryan May rmay31@gmail....
Thu Apr 23 11:26:49 CDT 2009


On Thu, Apr 23, 2009 at 11:23 AM, Christopher Barker
<Chris.Barker@noaa.gov>wrote:

> Ryan May wrote:
> > On Thu, Apr 23, 2009 at 9:52 AM, David Cournapeau <cournape@gmail.com
> >     But replacing print is not as easy as reduce. Things like print
> >     "yoyo", a do not work, for example.
> >
> > I think the point is that you can just change it to print("yoyo") which
> > will work in both python 2.x and 3.x.
>
> I think he meant:
>
> print "yoyo", a
>
> which can not be translated by adding parens:
>
>  >>> print "yoyo", a
> yoyo [ 1.  1.  1.]
>  >>> print ("yoyo", a)
> ('yoyo', array([ 1.,  1.,  1.]))
>
>
> I suppose we can write something like:
>
> def new_print(*args):
>    print (" ".join([str(s) for s in args]))
>
>  >>> new_print("yoyo", a)
> yoyo [ 1.  1.  1.]
>
>
> Though I'm a bit surprised that that's not how the print function is
> written in the first place (maybe it is in py3k -- I'm testing on 2.5)
>
> -Chris
>

Good point.  We could just borrow the implementation from 2.6 and in fact
just import print from future on 2.6.  Just a thought...

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090423/28bc189c/attachment.html 


More information about the Numpy-discussion mailing list