[PYTHON MATRIX-SIG] Something broken with __mul__?

Konrad Hinsen hinsen@ibs.ibs.fr
Fri, 18 Oct 96 17:36:34 +0100


> I try to build a class similar to UserArray, and have some
> problems. Here is my attempt.
> ...
>     a=a_mesh(data,dx,dz,Float32)
                          ^^^^^^^
> ...
>     print b*3
              ^
> ...
> If I change * to multiply in the definition, this is ok. But with the
> definition of 'less' I have no success. And if less is really a
> function and not a method, do I need a definition at all?

Just to add *why* multiplication with * fails: it doesn't
accept an integer and a Float32 as arguments. Making either
or both arguments float solves the problem.

I don't remember exactly the result of the long debate about
coercion and combination of different data types, but somehow
I think this is not correct...

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================