Most reliable/pythonic way to tell if an instance comes from a class implemented in C/etc?

Nathan Rice nathan.alexander.rice at gmail.com
Mon May 24 12:56:44 EDT 2010


I'm trying to do some fairly deep introspection and instrumentation of
instances and classes at runtime, and in order for everything to be properly
behaved I need to have radically different behavior in the event that the
thing passed to me is a wrapped class/instance.  Is there a really good way,
given an instance of a class, to determine if it is wrapped or native?
Currently I check to see if it has __slots__ then try to setattr a dummy
variable but I imagine there is probably a cleaner way.

Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100524/c257a41b/attachment.html>


More information about the Python-list mailing list