Discussion:
"compiler" module in Python3k
Zubin Mithra
2010-11-06 15:34:51 UTC
Permalink
Hello everyone!

I am currently working on porting a library over to Py3k and I am required
to replace the compiler module as it does not exist in 3.1. I tried
replacing the compiler module with the ast module, however that does not
meet my requirements.

I need an analogue for compiler.parse.getChildren in Python3k. Any ideas?
Thanks a lot.

Cheers!
Zubin
Martin v. Löwis
2010-11-06 15:55:13 UTC
Permalink
Post by Zubin Mithra
I am currently working on porting a library over to Py3k and I am
required to replace the compiler module as it does not exist in 3.1. I
tried replacing the compiler module with the ast module, however that
does not meet my requirements.
I need an analogue for compiler.parse.getChildren in Python3k. Any
ideas? Thanks a lot.
Can you please generalize a little more what this code is trying to
achieve? Most likely, the _ast module will help, perhaps also lib2to3.

Regards,
Martin
Georg Brandl
2010-11-06 18:02:56 UTC
Permalink
Post by Zubin Mithra
Hello everyone!
I am currently working on porting a library over to Py3k and I am required to
replace the compiler module as it does not exist in 3.1. I tried replacing the
compiler module with the ast module, however that does not meet my requirements.
I need an analogue for compiler.parse.getChildren in Python3k. Any ideas? Thanks
a lot.
ast.iter_child_nodes together with ast.iter_fields seems to do what you need.

Georg
--
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
Loading...