On Tue, 14 Dec 2021 at 13:53, Paul Royik <distantjob...@gmail.com> wrote:
>
> In any expression, how to factor a constant (that doesn't depend on certain 
> symbols)?
>
> For example (-2xy+2).factor_function(x,y) should give 2, (1-xy).
>
> as_coeff_mul doesn't work.

Maybe factor_terms is what you want:

In [50]: factor_terms(-2*x*y + 2)
Out[50]: 2⋅(-x⋅y + 1)

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxR8jyQh%2BXydGu%3D%2B0grKvhDJK81PtU0Aasw%2BVyryixU0pA%40mail.gmail.com.

Reply via email to