Note that :
sage: foo.expand() a*b - b^2 - a*c + b*cFrom foo.list? :
Docstring: Return the coefficients of this symbolic expression as a polynomial in x. INPUT: * "x" -- optional variable. OUTPUT: A list of expressions where the "n"-th element is the coefficient of "x^n" when self is seen as polynomial in "x".Therefore :
sage: foo.list() [-b^2 + b*c, b - c]Is indeed the list of foo’s coefficients of powers of a.
What you seek is :
sage: foo.operands() [a - b, b - c]HTH,
BTW, a better forum or this kind of questions is probably ask.sagemath.org.