ws6079 ws6079 - 9 months ago 37
Python Question

Implementing intersection operator for a set-like class in Python

I'm trying to implement a wrapper class which should ideally allow me to get the intersection of its elements using the notation:

a & b

Is there a specific method that I can implement to achieve this? (I know that the individual elements need to implement the

I'm currently getting the following error:

TypeError: unsupported operand type(s) for &: 'PropArray' and 'PropArray'


Try to override:

def __and__(self, *args, **kwargs): # real signature unknown
    """ Return self&value. """

in your class