Multiple types in domain

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

Multiple types in domain

emir
How to set multiple domains for a property?
range = OneOf([str, int])

Python below 3.9 doesn't support  str|int notation I think
Reply | Threaded
Open this post in threaded view
|

Re: Multiple types in domain

Jiba
Administrator
Hi,

The | operator is supported between classes, but not with Python types. You can use the Or class instead:

my_data_prop.range = [ Or([int, str]) ]

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Multiple types in domain

emir
Thank you, Jiba!

I will try