[Python-Dev] Re: [Fwd: Discussion: Introducing new operators formatrix computation]
Fredrik Lundh
Fredrik Lundh" <effbot@telia.com
Sat, 15 Jul 2000 10:46:28 +0200
Huaiyu Zhu wrote:
> The only real danger is=20
>=20
> 3. + a
> 3 .+ a
>=20
> But in this case pointwise operation does not make sense.=20
really? what if "a" is a froob?
class froob:
def __add__(self, other):
return other + 1.0
def __dotadd__(self, other):
return other + 1.0
>>> a =3D froob()
>>> print 3+a()
4.0
>>> print 3.+a()
SyntaxError: sorry, that doesn't make sense. try inserting a space.
>>> print 3. + a()
4.0
>>> print 3.0+a()
4.0
</F>