Feature request: "with ... as" syntax

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

Feature request: "with ... as" syntax

Stefan
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.
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: "with ... as" syntax

Jiba
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
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: "with ... as" syntax

Stefan
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.
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: "with ... as" syntax

Stefan
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
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: "with ... as" syntax

Jiba
Administrator
Hi,

I've added "with onto as o" in the development version.

Enjoy,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: "with ... as" syntax

Stefan
Thanks!