Instrumenting a class to see how it is used

Paul Moore p.f.moore at gmail.com
Thu May 10 09:46:19 EDT 2012


I'm trying to reverse-engineer some pretty complex code. One thing that would help me a lot is if I could instrument a key class, so that I'd get a report of when and how each method was called and any properties or attributes were accessed during a typical run.

I could do this relatively easily by just adding print calls to each method/attribute, but I was wondering - is there a library that does this sort of wrapping already? I tried writing my own but got bogged down in infinite recursion in _getattribute__ and couldn't see an easy way out.

If anyone has any suggestions, I'd be interested.
Thanks,
Paul.



More information about the Python-list mailing list