Trait disjunction?

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

Trait disjunction?

Des.P
Is it possible to have a trait-type disjunction?

class A(HasTraits): pass
class B(HasTraits): pass
class D(HasTraits):
   a_or_b_or_d = ??(Instance(A),Instance(B),This) # an A, B, or D

Thanks!

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Trait disjunction?

Warren Weckesser


On Sat, Sep 22, 2012 at 1:37 PM, Des.P <[hidden email]> wrote:
Is it possible to have a trait-type disjunction?

class A(HasTraits): pass
class B(HasTraits): pass
class D(HasTraits):
   a_or_b_or_d = ??(Instance(A),Instance(B),This) # an A, B, or D


You can use the Either trait:

    a_or_b_or_d = Either(Instance(A), Instance(B), This)


Warren
 
Thanks!

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Trait disjunction?

Chris Colbert
In reply to this post by Des.P
a_or_b_or_d = Either(Instance(A), Instance(B), Instance('D'))


On Sat, Sep 22, 2012 at 2:37 PM, Des.P <[hidden email]> wrote:
Is it possible to have a trait-type disjunction?

class A(HasTraits): pass
class B(HasTraits): pass
class D(HasTraits):
   a_or_b_or_d = ??(Instance(A),Instance(B),This) # an A, B, or D

Thanks!

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev