Pretty Printing in Docstrings

34 views
Skip to first unread message

SAMPAD SAHA

unread,
Aug 15, 2016, 7:29:08 PM8/15/16
to sy...@googlegroups.com
How to enable pretty printing in the docstrings?

Regards
Sampad Kumar Saha
Mathematics and Computing
I.I.T. Kharagpur



Aaron Meurer

unread,
Aug 15, 2016, 10:34:48 PM8/15/16
to sy...@googlegroups.com
The simplest way is to just call pprint manually. 

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+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CANzav4Gv4xQcf-8c3gZ7u7FEkJ2WBHziVmkfqxaxwUogkmshaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

SAMPAD SAHA

unread,
Aug 16, 2016, 5:06:55 AM8/16/16
to sy...@googlegroups.com
At terminal it is pretty printing the result but in the docstrings it is just wrapping the text into next line.

At terminal:
In [14]: pprint(b.load)
          -1                    -1                 0
R₁⋅<x>   + R₂⋅<x - 4>   + 6⋅<x - 2> 

At docstrings:
>>> b.load
    R1*SingularityFunction(x, 0, -1) + R2*SingularityFunction(x, 4, -1) + 6*SingularityFunction(x, 2, 0)

>>> pprint(b.load)
    R1*SingularityFunction(x, 0, -1) + R2*SingularityFunction(x, 4, -1) + 6*Singul
    arityFunction(x, 2, 0)




Regards
Sampad Kumar Saha
Mathematics and Computing
I.I.T. Kharagpur

Aaron Meurer

unread,
Aug 16, 2016, 12:26:10 PM8/16/16
to sy...@googlegroups.com
The docstring pprint is doing to use the ASCII pretty printer. If you haven't implemented ASCII pretty printing, then it is going to fall back to using the str printer.

You can disable the line wrapping with pprint(wrap_line=False).

Aaron Meurer

Shekhar Prasad Rajak

unread,
Aug 19, 2016, 5:48:48 PM8/19/16
to sympy
I think pprint(b.load, use_unicode=False) will also work.

--
Shekhar
Reply all
Reply to author
Forward
0 new messages