I am trying to write a deeply nested set of classes, attributes, bound methods, etc. to a HDF5 file using the h5py module for long-term storage. I am really close. The onl
Thanks to @user4815162342, I have been able to get this to work. Here is a slightly modified version that will return True for instances of old- and new-style classes:
#Added the check for old-style class
Py_TPFLAGS_HEAPTYPE = (1L<<9) # Include/object.h
def is_class_instance(o):
import types
return (bool(type(o).__flags__ & Py_TPFLAGS_HEAPTYPE)
or type(o) is types.InstanceType)