python 2.5 and ast

Andrea Crotti andrea.crotti.0 at gmail.com
Tue Nov 29 04:51:24 EST 2011


On 11/29/2011 03:55 AM, Dave Angel wrote:
>
> But don't forget to tag it as version specific, so it gets removed 
> when the later version of the library is available.  There are various 
> ways of doing that, but the easiest is probably to put a test in the 
> acceptance suite that fails if this code is used in 2.6 or later.
>

Ok thanks,
something like this is ok?
(or maybe I can use a try/catch and export my own if is not found in the 
standard library?)

from sys import version_info

if version_info[1] == 5:
     from psi.devsonly.ast import parse, NodeVisitor
else:
     from ast import parse, NodeVisitor




More information about the Python-list mailing list