easy way to change print order

17 views
Skip to first unread message

Chris Smith

unread,
Nov 2, 2019, 2:58:01 PM11/2/19
to sympy
Shouldn't there be an easier way to change printer settings than this:

>>> u = parse_expr("-5 + 2*x + 3 - 7*x + 5 - 3*x", evaluate=False); u
-7*x - 3*x + 2*x - 5 + 3 + 5
>>> u.args
(-5, 2*x, 3, -7*x, 5, -3*x)
>>> s=StrPrinter()
>>> s._default_settings['order'] = 'none'  # < -- isn't there a better way?
>>> s._print_Add(u)
-5 + 2*x + 3 - 7*x + 5 - 3*x

Aaron Meurer

unread,
Nov 5, 2019, 2:27:52 PM11/5/19
to sympy
The public API would be StrPrinter(dict(order="none")).doprint(u).

But you can also use sstr(u, order='none').

Aaron Meurer
> --
> 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+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/778a2537-da80-42df-9db1-a9c82293e791%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages