Owlready
Search
everywhere
only in this topic
Advanced Search
Feature request: "with ... as" syntax
Classic
List
Threaded
♦
♦
Locked
6 messages
Stefan
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Feature request: "with ... as" syntax
Hi,
I have a minor feature request. Would it be possible to support the "as" part of the with statement when working on ontologies? i.e.:
onto = or2.get_ontology(...).load()
with onto as o:
...
instead of having to use
with onto:
...
...and then working with the full name.
It's a minor thing but it would be convenient in making things a little bit more readable sometimes.
Jiba
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: Feature request: "with ... as" syntax
Administrator
Hi,
So, when using "with onto as o:", o would be the same as onto, that's right?
For example to write:
with get_ontology(...).load() as o:
o.x.y = z
Jiba
Stefan
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: Feature request: "with ... as" syntax
Yes, that's how I'd intuitively try to use it.
The reason is that my ontology is part of an object, and I'd prefer to not have to write objectname.onto every time.
Stefan
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: Feature request: "with ... as" syntax
In reply to
this post
by Jiba
> with get_ontology(...).load() as o:
> o.x.y = z
This is interesting, too, but I don't think it would be as useful, because it seems to me like the lifetime of the ontology would be limited to the with block.
I'm thinking more along the lines of
longnameontology = get_ontology(...).load()
with longnameontology as o:
o.x.y = z
Jiba
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: Feature request: "with ... as" syntax
Administrator
Hi,
I've added "with onto as o" in the development version.
Enjoy,
Jiba
Stefan
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: Feature request: "with ... as" syntax
Thanks!
Free forum by Nabble
Edit this page