Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中实现类集合的交集运算符_Python_Set Intersection - Fatal编程技术网

在Python中实现类集合的交集运算符

在Python中实现类集合的交集运算符,python,set-intersection,Python,Set Intersection,我正在尝试实现一个包装器类,理想情况下,它应该允许我使用符号获得其元素的交集: a&b 有没有一个具体的方法,我可以实现这一点?(我知道各个元素需要实现\uuuuuuuuuuuuuuuuuuuuuu散列和\uuuuuuuuuueq方法) 我当前遇到以下错误: TypeError: unsupported operand type(s) for &: 'PropArray' and 'PropArray' 尝试覆盖: def __and__(self, *args, **kwargs):

我正在尝试实现一个包装器类,理想情况下,它应该允许我使用符号获得其元素的交集:

a&b

有没有一个具体的方法,我可以实现这一点?(我知道各个元素需要实现
\uuuuuuuuuuuuuuuuuuuuuu散列
\uuuuuuuuuueq
方法)

我当前遇到以下错误:

TypeError: unsupported operand type(s) for &: 'PropArray' and 'PropArray'
尝试覆盖:

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

在你的课堂上

太棒了,这就成功了!事后看来似乎很明显,但我的谷歌fu让我失望了。