How to dynamically create a new Data Property

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

How to dynamically create a new Data Property

SPJ
Hi,

I'm looking for a way to dynamically create a new Data property or an Object property.

for example what I want is something like this

def createDataProperty(newProperty):
    class newProperty(DataProperty):
        range = [str]
        pass

I want a new data property by whatever the name I pass to "newProperty" variable.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: How to dynamically create a new Data Property

Lukas
i would suggest to try something like stated here:

https://owlready2.readthedocs.io/en/latest/class.html#creating-a-class

you only have to customize this one for your needs and add a dataproperty
SPJ
Reply | Threaded
Open this post in threaded view
|

Re: How to dynamically create a new Data Property

SPJ
Hi,

Thank you Lucas.

Did a bit of searching and found the answer here
http://owlready.8326.n8.nabble.com/How-to-create-Object-and-Data-Properties-dynamically-td244.html

Best Regards,
SPJ