On Sun, Apr 19, 2009 at 1:50 PM, Fabian Pedregosa <fab...@fseoane.net> wrote: > Ondrej Certik wrote: >> On Sun, Apr 19, 2009 at 5:17 AM, Fabian Pedregosa <fab...@fseoane.net> wrote: >>> This is useful for example when pretty printing to non-terminals >>> (web browsers via html, etc.) >>> --- >>> sympy/printing/pretty/pretty.py | 19 >>> +++++++++++++++---- >>> sympy/printing/pretty/tests/test_pretty_unicode.py | 6 ++++++ >>> 2 files changed, 21 insertions(+), 4 deletions(-) >>> >>> diff --git a/sympy/printing/pretty/pretty.py >>> b/sympy/printing/pretty/pretty.py >>> index 9a31e46..da335f0 100644 >>> --- a/sympy/printing/pretty/pretty.py >>> +++ b/sympy/printing/pretty/pretty.py >>> @@ -21,13 +21,18 @@ def __init__(self, profile=None): >>> self._settings = { >>> "full_prec" : "auto", >>> "use_unicode" : True, >>> + "wrap_line" : True, >>> } >>> >>> if profile is not None: >>> self._settings.update(profile) >>> >>> def doprint(self, expr): >>> - return self._print(expr).terminal_string() >>> + if self._settings["wrap_line"]: >>> + return self._print(expr).terminal_string() >>> + if self._settings["use_unicode"]: >>> + return unicode(self._print(expr)) >>> + return str(self._print(expr)) >> >> >> This looks good, only I don't understand the lines >> >>> + if self._settings["use_unicode"]: >>> + return unicode(self._print(expr)) >> >> e.g. what does unicode have to do with wrap_line? Are you also fixing >> some other bug? > > I attach a reworked patch. The only change is: > > - return self._print(expr).terminal_string() > + if self._settings["wrap_line"]: > + return self._print(expr).terminal_string() > + return '\n'.join(self._print(expr).picture) > > so I basically let StringPict.picture decide wether a str or a unicode > should be returned. I think it is more elegant this way.
Excellent, now it's finally +1 from me. :) Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---