[Python-Dev] Recent experience with the _ast module
Collin Winter
collinw at gmail.com
Wed Feb 14 02:00:30 CET 2007
On 2/12/07, Brett Cannon <brett at python.org> wrote:
> They all sound reasonable. And it's nice to have a wanted feature be
> found from actual use. =)
I've just uploaded patch #1659410 to SF, implementing the changes I outlined:
1) I changed some of the code emitted by asdl_c.py so _fields is
always a tuple. Where _fields used to be None, it's now a 0-element
tuple.
2) It turned out that {BinOp, BoolOp,AugAssign,etc}.op were already
singleton instances of their respective classes. I've changed
asdl_c.py to no longer emit the *_singleton names and to use the
corresponding *_type types in their place, which will enable me to
write "node.op is _ast.Add", etc.
3) Adding an Else node was a little more involved, but it proved
do-able. TryFinally.orelse, While.orelse, For.orelse and If.orelse can
now be either None or an instance of Else. Else instances have a
'body' attribute, which is a sequence of statements.
Thanks,
Collin Winter
More information about the Python-Dev
mailing list