I would use expr.factor(deep=True) and if that didn’t work, then expr.replace(lambda x: x.is_Mul or x.is_Add, lambda x: x.factor()).
Regarding formatting in Google groups, see here where the recommended Markdown extension for Chrome was used to format this message.
I typed the following and then hit the extension icon and got what you see above
I would use `expr.factor(deep=True)` and if that didn't work, then `expr.replace(lambda x: x.is_Mul or x.is_Add, lambda x: x.factor())`.
Regarding formatting in Google groups, see [here](https://webapps.stackexchange.com/questions/36030/insert-code-sample-into-a-google-groups-post) where the recommended Markdown extension for Chrome was used to format this message.
/c
This is what your code looks like after prefixing with ‘’’python and suffixing with ‘’’ (where back tics were used instead of single quotes):