Skip to content

Is there a way to inject additional information into objects for pretty printing... #24584

Answered by gutow
gutow asked this question in Q&A
Discussion options

You must be logged in to vote

A partial solution for IPython that allows injection of a process before the pretty printing, but does not readily allow for modification of what is pretty printed by sympy uses the following pattern to hook into the IPython display formatter.

from IPython import get_ipython
ip = get_ipython()
formatter = ip.display_formatter
formatter.formatters['text/latex'].for_type(Basic, print_something ) # where print_something is a function that takes the expression as input.

This could also be used to hook into any of the other display types: ['text/plain', 'text/html', 'text/markdown', 'image/svg+xml', 'image/png', 'application/pdf', 'image/jpeg', 'text/latex', 'application/json', 'application/j…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by gutow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant