Getting the type of an AST Node
Nick Edds
nedds at uchicago.edu
Sat Mar 28 08:32:33 EDT 2009
Ahh sorry. This was in Python 2.5.
On Sat, Mar 28, 2009 at 1:20 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> Nick Edds wrote:
>
>> Is there an easy way to figure out what the type of an AST Node is?
>>
>
> Specify version.
>
> ? If I
>
>> have a node n, doing type(n) doesn't help because it gives me <type
>> 'instance'>,
>>
>
> Sounds like instances of an old-style class. Gone in 3.0. You might try
> AST in 3.0 to see what you get.
>
>
>
> but what I really want is If, or And, or whatever node type
>
>> the node actually is. I could always just look at n.__repr__(), because
>> the repr for each node type is in the format NodeType(x), but this seems
>> like an inelegant solution.
>>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090328/5a4a6ecb/attachment.html>
More information about the Python-list
mailing list