[PYTHON MATRIX-SIG] Coercion problems solved?
Konrad Hinsen
hinsen@ibs.ibs.fr
Sun, 9 Mar 1997 19:26:12 +0100
> Then I remembered that Python is not an assembler with structs but is
> an object-oriented language. A few minutes yielded:
>
> import UserArray
> class array32(UserArray.UserArray):
> def __init__(self, sequence):
> UserArray.UserArray.__init__(self, sequence, typecode='f')
> def __coerce__(self,other):
> return (self, UserArray.UserArray(other, typecode='f'))
This sounds like a very good approach. Maybe we should even put
something like this into the standard distribution, if only as
an example for specializing arrays.
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale | Fax: +33-4.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
_______________