Implementing __concat__
Posted
by Casebash
on Stack Overflow
See other posts from Stack Overflow
or by Casebash
Published on 2010-03-08T10:17:36Z
Indexed on
2010/03/08
10:21 UTC
Read the original article
Hit count: 424
I tried to implement __concat__
, but it didn't work
>>> 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'
How can I fix this?
© Stack Overflow or respective owner