Here is an example:
from owlready2 import *
onto = get_ontology("
http://test.org/onto.owl")
with onto:
class C(Thing): pass
class prop(Thing >> Thing): pass
class D(C):
is_a = [prop.only(C)]
for i in D.is_a:
if isinstance(i, Restriction):
if i.type == ONLY:
print("AllValuesFrom restriction on property", i.property, "and class", i.value)
=>
AllValuesFrom restriction on property onto.prop and class onto.C