Label-Value (was: Re: Inheriting the @ sign from Ruby)
Carsten Geckeler
nospam at no.spam
Fri Dec 15 13:51:03 EST 2000
On Fri, 15 Dec 2000, Rainer Deyke wrote:
[snip]
> Yes, in-place modification should be supported. I had something like this
> in mind:
>
> class UserInt:
> def __init__(self, value):
> self.data = value
> def __add__(self, other):
> if isinstance(other, UserInt):
> return self.__class__(self.data + other.data)
> else:
> return self.__class__(self.data + other)
> __radd__ = __add__
> def __iadd__(self, other):
> if isinstance(other, UserInt):
> self.data += other.data
> else:
> self.data += other
There is a `return self' missing at the end of the __iadd__ method.
Cheers, Carsten
--
Carsten Geckeler: carsten dot geckeler at gmx dot de
To get proper email-address replace `dot' and `at' by the corresponding symbols.
More information about the Python-list
mailing list