inconsistency with += between different types ?
Andreas Leitgeb
Andreas.Leitgeb at siemens.at
Wed Aug 7 14:32:49 EDT 2002
Bernhard Herzog <bh at intevation.de> wrote:
> list-python at ccraig.org (Christopher A. Craig) writes:
>> Andreas.Leitgeb at siemens.at (Andreas Leitgeb) suggested:
>>> [ restrict __i...__-methods to enforce sane-ness ]
>> You do realize that at the end of this += would only apply to lists
>> [...] Because ints,
>> longs, floats, tuples, and in the future rationals are all immutable
>> and thus cannot return self.
>
> So what? Immutable objects don't have to implement __iadd__ et al. at
> all and in fact ints don't have __iadd__. Python falls back to calling
> __add__ and normal assignment automatically.
That's exactly what I meant.
For immutable objects, __iadd__ et al. simply make no sense (IMHO).
To Christopher and other defendants of status quo:
Do you know of any real use that a not-self-mutating __ixxx__
may have, which its non-i version __xxx__ could not do ?
(I do *not* intend to argue that just because you perhaps cannot think
of any at the moment, that the suggestion would necessarily be good,
but if instead you happen to know a good use then we could instantly
short-cut the discussion.)
PS: The ability to write intendedly obfuscated Python does not count :-)
--
Newsflash: Sproingy made it to the ground !
read more ... <http://avl.enemy.org/sproingy/>
More information about the Python-list
mailing list