Behavior of += (was Re: [Python-Dev] Customization docs)

Donn Cave donn at
Wed Jun 5 02:04:34 EDT 2002

Quoth huaiyu at (Huaiyu Zhu):
| That is one proposal.  My proposal is to disallow += for immutables.
| Another symbol would be used for rebinding operations.  (Or maybe swap the
| role of these symbols.)  Thus for mutables both operations would be
| available.

That suits me, except the mutable/immutable distinction.  That's
how we have been describing the distinction, but it's worth noting
that it isn't really what we mean.

For a silly example, suppose that in 2.3, None supports +=, kind of
like the UNIX /dev/null.  This would not make it mutable in any
reasonable sense of the word, but it's in the "in place" category.
A class instance that implements __iadd__ to return something other
than self, would not be, though it's certainly mutable.

	Donn Cave, donn at

More information about the Python-list mailing list