On Thu, Apr 23, 2009 at 11:23 AM, Christopher Barker
<[email protected]>wrote:

> Ryan May wrote:
> > On Thu, Apr 23, 2009 at 9:52 AM, David Cournapeau <[email protected]
> >     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
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to