On Monday, April 27, 2015 at 4:45:42 AM UTC-4, Martin R wrote:
>
> Is there any concise description (possibly proposed) of what the different 
> output functions should do?  I know of the following functions, and have my 
> personal expectations, but I'd be interested in others:
> __repr__
> print
>

We should be able to agree on these as they are part of the plain Python 
language.

* __repr__ (or SageObject._repr_): return a string

* print:Immediately sends the output of __repr__ to stdout

* displayhook: calls __repr__ on the value of the last statement and sends 
to stdout

>>>: 123
123          <-- displayhook at work

In Sage, the displayhook does more refined things like

sage: plot(sin)
Launched png viewer for Graphics object consisting of 1 graphics primitive

or displaying the graphics inline in various notebooks.


show
> pretty_print


Now (#17821): show = pretty_print is like print() but with rich output, so 

sage: def f():
...:    print(123)
...:    pretty_print(plot(sin)) 
sage: f()
123
Launched png viewer for Graphics object consisting of 1 graphics primitive

Before #17821: show and pretty_print does slightly different and, at least 
to me, not very self-explanatory things. For example, in the SageNB 
notebook:

g = Graph({1:[2]})
g             #  a picture of the graph created using tkz -> pdf -> png if 
the "typeset" checkbox is on
show(g)   # a picture of the graph created with matplotlib
pretty_print(g)   # tkz picture again, but this time regardless of the 
"typeset" checkbox setting
show(WeylCharacterRing('E8'))  # a png picture containing the words "the 
Weyl Character Ring..."

 

> latex
>
ascii_art

plot


latex() returns a latex code object containing code suitable for 
typesetting in a math environment.
 
ascii_art() returns an ascii art object that can be used as building block 
for building larger ascii art displays

plot() returns a graphics object that can be saved or composed into more 
complicate graphics


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to