On Sep 2, 2009, at 12:17 PM, Ben Dunlap wrote:

I've got some sample code written that first calls get_class_methods()
to list the names of all the visible methods of the parent object,
then constructs code to declare a child class that overrides those
methods with wrapper methods, and finally eval()s the declaration and
instantiates an object of the new class.

You're right; that is evil.

But, interesting idea. It turns out for my specific purposes (a generic decorator that measures a class's method execution times), a full-fledged profiler like APD is really what I need, but I'll keep this in mind for getting around the type-hinting, should the need arise again.

David Kurtz

Reply via email to