Sunday 12 December 2004This is over 18 years old. Be careful.

After a long and feverish ten days spent poring over Python parse trees, I have an updated to offer.

It does a better job identifying executable statements than the original version by Gareth Rees, which was confused by docstrings and global statements. And you can use code markers to exclude lines or suites from consideration as executable statements.


In the end, this job required a three-pronged attack to get everything I needed out of a Python module. Line-oriented regular expressions found the exclusion markers, the parser module told me about tokens and line numbers, and the compiler module told me about execution semantics. There may be an easier way to get all the information I needed, but I couldn’t find it.


Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.