INDIRECT_is_a dose not work as I thought. (closed)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

INDIRECT_is_a dose not work as I thought. (closed)

William
This post was updated on .
Following is the code.
'''
class: Person
property: love: Person->Person
'''
with onto:
    class love(Person >> Person):
        pass

    Person.is_a.append(love.some(Person))  # a person loves someone.

    x = Person('x')

print(love.some(Person) in Person.is_a) # True
print(Person in x.INDIRECT_is_a) # True
print(love.some(Person) in x.INDIRECT_is_a) # False, excepted to be True, since x loves someone
print(love.some(Person) in x.INDIRECT_is_instance_of) # False
print(x in x.love) # False

while, following is OK
    class love_person(Person):
        equivalent_to = [Person & love.some(Person)]

print(love_person in x.INDIRECT_is_instance_of)  # True, however, it is equivalent to the statement above


An additional question is that Person has no INDIRECT_is_a property.
Reply | Threaded
Open this post in threaded view
|

Re: INDIRECT_is_a dose not work as I thought.

Jiba
Administrator
Hi,

INDIRECT_is_a was limited to plain classes, excluding class constructs (such as "some").

I corrected this in the development version on BitBucket. I also added a "include_constructs" option to Class.ancestors(), which defaults to False (for backward compatibility).

Finally, I've added INDIRECT_is_a to classes.

Jiba