This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xiang.zhang
Recipients xiang.zhang
Date 2017-01-03.09:58:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483437510.5.0.880271510583.issue29139@psf.upfronthosting.co.za>
In-reply-to
Content
As the title, but I think it should also continue if only the right operand is a sequence since the right operand could get a __radd__ to do the concatenation:

>>> class S:
...     def __init__(self):
...             self.v = list(range(10))
...     def __radd__(self, other):
...             print('in __radd__')
...             self.v.extend(other)
...             return self.v
...     def __getitem__(self, idx):
...             return self.v[idx]
>>> def i():
...     yield from range(10, 20)
>>> i() + S()
in __radd__
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> operator.concat(i(), S())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'generator' object can't be concatenated
>>> a = i()
>>> a += S()
in __radd__
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> a = i()
>>> operator.iconcat(a, S())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'generator' object can't be concatenated
History
Date User Action Args
2017-01-03 09:58:30xiang.zhangsetrecipients: + xiang.zhang
2017-01-03 09:58:30xiang.zhangsetmessageid: <1483437510.5.0.880271510583.issue29139@psf.upfronthosting.co.za>
2017-01-03 09:58:30xiang.zhanglinkissue29139 messages
2017-01-03 09:58:30xiang.zhangcreate