views:

66

answers:

2

Hi,

I am trying to write a Python code analyzer, and I am trying to avoid having to parse bare Python text files. I was hoping that once the Python compiler/interpreter parses the code there's a way to get to the object code or parse tree from within a running Python program.

Is there anyway to do this?

Thank you

+1  A: 

You can take a look at Python's abstract syntax trees.

Colorado
+1  A: 

A combination of ast and tokenize should provide the necessary framework for what you want to do.

Dan McDougall