[Python-Dev] Exposing the abstract syntax (original) (raw)

martin at v.loewis.de martin at v.loewis.de
Sun Feb 26 20:59:09 CET 2006


At PyCon, there was general reluctance for incorporating the ast-objects branch, primarily because people where concerned what the reference counting would do to maintainability, and what (potentially troublesome) options direct exposure of AST objects would do.

OTOH, the approach of creating a shadow tree did not find opposition, so I implemented that.

Currently, you can use compile() to create an AST out of source code, by passing PyCF_ONLY_AST (0x400) to compile. The mapping of AST to Python objects is as follows:

It might be reasonable to expose this through a separate module, in particular to provide access to the type objects.

Regards, Martin



More information about the Python-Dev mailing list