inconsistency with += between different types ?

Donn Cave donn at u.washington.edu
Mon Aug 5 15:50:25 EDT 2002


Quoth Jonathan Hogg <jonathan at onegoodidea.com>:
| On 5/8/2002 17:10, in article
| slrnakt9pu.c05.Andreas.Leitgeb at pc7499.gud.siemens.at, "Andreas Leitgeb"
| <Andreas.Leitgeb at siemens.at> wrote:
|> The question seems to be:
|> Is an extended assignment(*) a "modification" of an object or
|> a re-assignment to the left-side operand ?
|> 
|> Is it just a question of whether and how __iadd__ is implemented,
|> or is there some deeper meaning in this ?
|> Is it a bug ?  
|
| There's a deeper meaning ;-)
| Lookup "mutable" types.
|
| Hint: a list is "mutable", a string and an integer are not.

The way I see it, he's right on target with ``whether and how __iadd__
is implemented''  It's true that you can't expect to see immutable
objects modified, a contradiction in terms, but you certainly can
implement a mutable object that reassigns to the left hand side.
So mutability isn't the real issue (as usual.)

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list