Compiler, ast and forwards/backwards compatibility

Terry Reedy tjreedy at udel.edu
Tue Oct 7 12:39:21 EDT 2008


Orestis Markou wrote:
> Hello,
> 
> I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a
> static analysis/intellisense provider for Python. I am targeting
> Python 2.4 code so I'm using the compiler package.
> 
> I've been toying around yesterday with the ast module in Python 2.6
> and it seems much more cleaner. One thing I don't understand is how
> should one handle backwards and forwards compatibility.

My impression is that the 2.6 ast package is quite different from the 
2.4 compiler package, but I have not looked at it (in its 3.0 version) 
yet.  If the 2.4 code you are analyzing is syntactically and sematically 
valid as 2.6 code, which I believe is usual, then of course there is no 
problem.  If it is not, then I would not be sure.

> I guess that Python 2.6 can target Python 2.3-6, and with specific
> compiler flags it can also target 3.0, so it seems that the correct
> thing to do is to use that.

If you want to target 2.3 to 3.0, 2.6 is the only option as far as I 
know.  I expect you will want to run your code through 2to3 (still being 
improved) and run under 3.0 to properly handle 3.0 code.

Maybe someone else can give a better answer.

tjr




More information about the Python-list mailing list