Discussion:
A question about running 2to3 on projects in progress
Vinay Sajip
2012-03-03 12:21:10 UTC
Permalink
Hi,

Suppose a project is being ported using 2to3, and there are some parts of the
codebase which have been converted and others which haven't. 2to3 currently
doesn't like some 3 features when parsing, e.g. print('abc', file=sys.stdout) in
the source causes a parse error at the '='. Is there any way around this, e.g.
picking another grammar dynamically, or is it baked in?

Regards,

Vinay Sajip
Lennart Regebro
2012-03-03 12:25:17 UTC
Permalink
Post by Vinay Sajip
Hi,
Suppose a project is being ported using 2to3, and there are some parts of the
codebase which have been converted and others which haven't. 2to3 currently
doesn't like some 3 features when parsing, e.g. print('abc', file=sys.stdout) in
the source causes a parse error at the '='. Is there any way around this, e.g.
picking another grammar dynamically, or is it baked in?
Well, you have to convert only those files who haven't been converted.
Or if you mean that some things (like print) has been converted
already, you can skip those fixers.

But code that are inconsistently mixing Python 2 and Python 3 idioms
can't be converted with 2to3 as far as I know.

//Lennart
Vinay Sajip
2012-03-03 12:59:48 UTC
Permalink
Post by Lennart Regebro
Well, you have to convert only those files who haven't been converted.
Or if you mean that some things (like print) has been converted
already, you can skip those fixers.
But code that are inconsistently mixing Python 2 and Python 3 idioms
can't be converted with 2to3 as far as I know.
I thought that might be the case, but no harm in checking! Thanks.

Regards,

Vinay Sajip

Loading...