Best way to handle sequences

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

Best way to handle sequences

franzlst
Ontologies do not directly support sequences, i.e. properties with multiple ordered values. This is why for this hasFirst and and hasNext properties (or subclasses properties) are used

Dummy example:
p = Progress()
s1 = Step()
s2 = Step()
p.hasFirst = s1
s1.hasNext = s2

As it is a bit cumbersome to access such sequences, I'm wondering how this could be simplified using Owlready2. I would like to be able to access (both read and write) such information using e.g.
p.steps

I could imagine that could be implemented using custom Python methods. Would this be the appropriate way or are there better alternatives?
Reply | Threaded
Open this post in threaded view
|

Re: Best way to handle sequences

Jiba
Administrator
Hi,

> I could imagine that could be implemented using custom Python methods. Would this be the appropriate way or are there better alternatives?

Yes, I think it is the appropriate approach. You can create a get_steps() method, and then a "step" property if you want to access it without having to call the method.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Best way to handle sequences

franzlst
Thanks!