class IdentityObject(Thing):
def import_identity_data(self, xml_object):
self.import_attribute(xml_object, has_for_uuid, "uuid", True)
self.import_attribute(xml_object, has_for_name, "name", True)
和一堂课
class Base():
def __init__(self):
pass
def import_attribute(self, xml_object: etree._Element, prop, name: str, is_mandatory: bool):
property_name = prop.python_name
attribute = xml_object.attrib.get(name)
attribute = prop.range[0](attribute)
if attribute is None:
if is_mandatory:
raise AttributeError(name + " needs to exist!")
else:
setattr(self, property_name, attribute)
我想创建一个子类
class Object(IdentityObject,Base):
pass
但我得到了错误
Class.namespace.ontology._add_obj_triple_spo(Class.storid, Class._rdfs_is_a, base.storid)
AttributeError: type object 'Base' has no attribute 'storid'
所以问题是,owlready2 希望 Class Base 也从 Thing 继承,这是一个问题,因为如果这样做,它将在本体中显示为对象。
owlready2有没有办法继承一个python类和一个owlready2类到同一个对象?