surprising += for lists
Terry Reedy
tjreedy at udel.edu
Sun Nov 4 12:57:11 EST 2012
On 11/4/2012 7:45 AM, Dave Angel wrote:
> What I wonder about is why list's __add__ is so fussy.
Guido's reason is that it is not clear what the types of [1,2] + (3,4),
(1,2) + [3,4], [] + range(4), range(2) + [3,4], etcetera should be. Such
mixtures may be bugs. Seq.__add__ exists to implement '+'.
[].extend() will clearly be a list, and accepts any iterable.
I believe the same logic is used for set operations.
--
Terry Jan Reedy
More information about the Python-list
mailing list