Open yoavnash opened 4 years ago
Perhaps related to #416
I guess we could have a solution, where we define such shortcuts somewhere. I'm not sure whether we should, though...
What do you think @ahashibon
Why shouldn't we? Perhaps we could use another kind of syntax if we don't want to overload the dot notation.
Yeah, I don't know if overloading the dot notation is wise.
Any ideas for an alternative syntax?
How about isbn = book.get(attr=ns.isbn)
?
Another suggestion: support aliases defined in the code. As an illustration:
set_alias(alias='position', oclass=onto.Atom, func=lambda atom: atom.get(onto.Position)[0].vector)
...
a = onto.Atom()
...
p = a.position
I think this could become handy 👍
Often an interesting value hides inside some internal CUDS object, which requires to do a few
get
calls in order to fetch it. For example:This is quite cumbersome, and therefore I often prefer to define often-accessed values as attributes. That is:
Is there a way to have a dot notation that is just syntactic sugar for a series of
get
calls for a more complex CUDS structure? So the user uses the code as in snippet 2 but behind the scenes a series ofget
calls is run, as in snippet 1. Another thing to point out here is that the user should be able to define these "shortcuts" by himself, probably in the YAML file.What do you think?