[Python-Dev] Policy for making changes to the AST
Eugene Toder
eltoder at gmail.com
Sun Apr 3 06:24:04 CEST 2011
> However, I'm not sure we *can* do a general-purpose AST transformation
> that handles both new nodes and changes to existing nodes correctly
> for all applications.
As long as both versions contain the same information we can write a
transformation that does a near-perfect job.
E.g. for my changes I can write a convertor that produces AST in
almost the same form as the current one, the only change being the new
'docstring' attribute set to None. (That's for converting AST before
optimizations, after optimizations it can contain nodes that couldn't
be represented before). I believe it's similar for Try change that
Benjamin mentioned above.
Also, if written in Python, conversion can at least serve as a
template even if it doesn't work out of the box.
Eugene
More information about the Python-Dev
mailing list