є дві ф-ції isinstance і issubclass але вони видають не то. повинно видавати шось типу того
>>> class A(object): ... """ ... """ ... >>> PyType_Check(A()) False >>> PyType_Check(dict()) True
>>> issubclass(dict, type) False >>> isinstance(dict(), type) False >>> isinstance(A(), type) False >>> issubclass(dict, type) False >>> issubclass(A, type) False
кусок сішного коду:
/* Sanity check the value given to make sure it is allowed in the cache */ if (PyType_Check(v)) { /* Its a persistent class, such as a ZClass. Thats ok. */ } else if (v->ob_type->tp_basicsize < sizeof(cPersistentObject)) { /* If it's not an instance of a persistent class, (ie Python classes that derive from persistent.Persistent, BTrees, etc), report an error. TODO: checking sizeof() seems a poor test. */ PyErr_SetString(PyExc_TypeError, "Cache values must be persistent objects."); return -1; }