On Wed, Nov 28, 2012 at 6:50 PM, ThanhVu Nguyen <[email protected]> wrote: > > > On Wednesday, November 28, 2012 2:01:59 AM UTC-5, Aaron Meurer wrote: >> >> On Tue, Nov 27, 2012 at 8:48 PM, ThanhVu Nguyen >> <[email protected]> wrote: >> > Hi, I came from the Sage (sagemath) background and am trying to use >> > Sympy >> > for my new project instead. >> > >> > I am wondering how to obtain the coefs and terms of a given expression >> > in >> > sympy. For example, given the expression a**2+b+5*c+2, I want to get >> > the >> > coefs [1,1,5,2] and the terms [a^2,b,c,1]. >> >> If you are just working with polynomials, the easiest way is to use >> the Poly class, and use the all_coeffs method. > > > Do you mean convert my expression to Poly and use the all_coefs method ? I > did that but it doesn't support multvariate poly > Poly(a**2+b+5*c+2).all_coeffs() > PolynomialError: ..
Oh I guess you just want expr.coeffs() then, or expr.terms(). Aaron Meurer > > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sympy/-/thgKwRaQ5wsJ. > > 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. -- 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.
