[Python-3000] print() parameters in py3k
jimjjewett at gmail.com
Mon Nov 20 21:57:25 CET 2006
On 11/20/06, Barry Warsaw <barry at python.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> On Nov 20, 2006, at 12:14 PM, Josiah Carlson wrote:
> > How much print statement rewriting do you want to do? Me, I'd like to
> > get away with as little as possible. Adding parenthesis isn't that
> > bad.
> > Changing everything to use a printf-style would be 1) annoying, 2)
> > unnecessary, and 3) I hate printf.
> Are we going to include a flawless transformation script for Python
> 3k? If not, then I'm pretty much resigned to rewriting them by hand
Assuming no further changes to PEP 3105, then it should be possible,
at least for the print statement.
Just parse the thing into statements; when you get to a print
statement make the string replacement before writing it back out.
The "print" literal translates into "print(" ... ")"
">>" file_expression moves to the end and translates into
the printable_expression stays the same
a trailing comma translates into "end=''" (an empty string)
(legacy code never uses the sep keyword)
More information about the Python-3000