how to make subclass of set return an instance of subclass from __and__, __sub__ and __or__

前端 未结 0 1639
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-22 17:17
class MySet(set):
  def showme(self):
    print(self)
s1 = MySet([1, 2, 3])
s2 = MySet([2, 3, 4])
(s1&s2).showme()

should output:

{2         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题