On Mon, Nov 10, 2008 at 10:46 PM, Brian Granger <[EMAIL PROTECTED]> wrote: > > Never mind, I figured this out myself: > > On Mon, Nov 10, 2008 at 1:15 PM, Brian Granger <[EMAIL PROTECTED]> wrote: >> OK, sounds great. Now a follow on....or two... >> >> * How can I get the non-commuting part of the Mul? I see that >> Mul.flatten knows about it, but I don't see how to get it back. > > Just do > > Mul.flatten(o.args) where o is my Mul instance > >> * I then need to take an expression, find all the instances of Mul in >> the tree and replace those by something else, one by one. Is there a >> simple way of doing this? the most common usage case that I will have >> is a sum of terms; > > Use o.atoms(Mul) to get a set of all the Mul instances and then use > o.subs(old, new) to rewrite them all.
Yes, that's actually also a solution -- you now know sympy more than I do. :) Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---