Vinay Sajip | 3 Mar 2012 13:21
Picon
Favicon
Gravatar

A question about running 2to3 on projects in progress

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 | 3 Mar 2012 13:25
Picon
Gravatar

Re: A question about running 2to3 on projects in progress

On Sat, Mar 3, 2012 at 13:21, Vinay Sajip <vinay_sajip@...> wrote:
> 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 | 3 Mar 2012 13:59
Picon
Favicon
Gravatar

Re: A question about running 2to3 on projects in progress

Lennart Regebro <regebro <at> ...> writes:

> 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

Gmane