Am 24.05.2010 13:43, schrieb luper rouch: > Yes I certainly missed that in the docs, sorry. So, arithmetic > operators are some kind of static methods, is the following the right > way to implement them ? > > def __mul__(op1, op2): > if isinstance(op1, Quaternion): > return from_c_obj((<Quaternion>op1).wrapped[0] * <float>op2) > else: > return from_c_obj((<Quaternion>op2).wrapped[0] * <float>op1) > > And for intransitive operations like __div__ return NotImplemted in > the reversed case : > > def __div__(op1, op2): > if isinstance(op1, Quaternion): > return from_c_obj((<Quaternion>op1).wrapped[0] / <float>op2) > else: > return NotImplemented >
Slightly-or-not-so-slightly off-topic, but are you by any chance wrapping Bullet? I also started with that [1] (unfortunately, my dedication has already begun to decline). D'you have any code or site online somewhere? Regards, Felix -- [1] http://bitbucket.org/fk/python-bullet _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
