[issue29139] operator.concat/iconcat could only work if left operand is a sequence

Serhiy Storchaka report at bugs.python.org
Tue Jan 3 05:17:17 EST 2017


Serhiy Storchaka added the comment:

I don't think it should. You can use operator.add() if you need to fall back to a __radd__ of the right operand.

operator.concat() is Python API to the sq_concat slot. It falls back to __add__() just because instances of user classes defining an __add__() method only have an nb_add slot, not an sq_concat slot.

Third-party classes (maybe NumPy arrays, I don't know) can have different implementations of sq_concat and nb_add.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29139>
_______________________________________


More information about the Python-bugs-list mailing list