Implementing __concat__ in Python
我试着实现
1 2 3 4 5 6 7 8 9 10 11 12 | >>> class lHolder(): ... def __init__(self,l): ... self.l=l ... def __concat__(self, l2): ... return self.l+l2 ... def __iter__(self): ... return self.l.__iter__() ... >>> lHolder([1])+[2] Traceback (most recent call last): File"<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'lHolder' and 'list' |
我怎么修这个?
您需要实现
您希望实现