Ian Kelly wrote:
If the in-place behavior of += is held to be part of the interface, then we must accept that += is not polymorphic across mutable and immutable types,
That's quite correct, it's not. As I said, it's one notation doing double duty. Usually there isn't any confusion, because you know whether any particular instance of it is intended to operate on a mutable or immutable type. If that's not the case -- if you're writing a function intended to operate on a variety of types, some mutable and some not -- then using in-place operators would not be appropriate.
If you want in-place concatenation, the obvious way to do it is by calling extend.
It might be the obvious way for that particular operation on that particular type. But what about all the others? What's the obvious way to spell in-place set intersection, for example? (Quickly -- no peeking at the docs!) The in-place operators provide a standardised spelling for in-place versions of all the binary operations. That's a useful thing to have, I think. -- Greg -- https://mail.python.org/mailman/listinfo/python-list