On Mon, Nov 10, 2008 at 13:16, Brian Granger <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> By default, Python's * operator work in L->R order, so:
>
> a*b*c*d = ((a*b)*c)*d
>
> But, I am implementing some operators from quantum mechanics that I
> want to apply like this:
>
> a*b*c*d = a*(b*(c*d))
>
> Is this possible with sympy?  In my case, a, b, c, and d are custom
> subclasses of Basic that don't commute.  I would like to do this using
> a custom __mul__ method on my class, but I am not sure that will work.
>
> Any thoughts?

Associativity of operations is handled by the parser, not the classes.
You might be able to fake it by making __mul__ unimplemented and only
implement __rmul__, but that might be fragile.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to