Ah, I forgot that if factor is not a number, it won't distribute
automatically. You'll want to do something like
n, d = expr.as_numer_denom()
expand(n*factor)/expand(d*factor)
The way it is now, factor just immediately cancels.
And by the way, if your goal is to write a rational function in
reduced terms, you can use cancel() or factor() (the latter will also
factor the numerator and denominator).
Aaron Meurer
>
https://groups.google.com/d/msgid/sympy/2d2bbab6-ed5c-4a9a-957f-51986b4f40e8%40googlegroups.com.