Thus 'show', whose meaning is quite different from pretty_print, will
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__
show
pretty_print
latex
ascii_art
plot
__repr__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
* __repr__ (or SageObject._repr_): return a string* print: Immediately sends the output of __repr__ to stdoutI think it sends __str__ to stdout.
Could you please comment, what you'd like to change?
Except for plot, the results seem relatively consistent to me, but of course, this may be because I'm using the console.
Thats not really the topic but why not...
* view() should be renamed to something that is suggestive of what it actually does, maybe pdflatex(). In http://trac.sagemath.org/ticket/18116 I'm proposing latex(x).compile(), though that ticket doesn't change view()
* The commandline backend shouldn't claim to support latex output, so pretty_print(x) wouldn't output implicit latex on the commandline. If anything it is worse than ascii art and plain text in that UI. If you specifically ask for latex output via latex(x) then you will get it of course.
* Add a warning (or deprecation) in show() to use pretty_print() instead as it is more indicative of what it actually does. This is #18302
* Similar to latex(), there is a html() function. This should be changed to return the existing html container object instead of the current behavior of printing to stdout and returning the empty html container. This is #18292
Except for plot, the results seem relatively consistent to me, but of course, this may be because I'm using the console.plot(x) essentially just calls x.plot(), and it'll necessarily fail if there is no graphical representation defined. I think that is unavoidable. I'd rather not have a plot(x, do_show=True) optional keyword argument as an "abbreviation" for plot(x).show(), but then there are definitely bigger fish to fry.
So, plot(x) would have no side effect, instead I would have to call show() on the result? Slightly weird, but still OK for me.
On Tuesday, April 28, 2015 at 12:35:57 PM UTC-4, Martin R wrote:So, plot(x) would have no side effect, instead I would have to call show() on the result? Slightly weird, but still OK for me.Not sure I understand, so just to clarify: The current behavior is that plot() has no side effects, and p.show() has side effects but no return value.
I have read this thread, but I fail to understand the reason. Eg., there is a commit "extrawurst for graphs". I thought that by default all objects would display in the console their repr. The commit seems to indicate that this doesn't work for graphs. Why?
But why do we get _rich_repr_ on the console in the first place???
Oh, now that's an explanation! So the explanation in the third post on this thread,
displayhook: calls __repr__ on the value of the last statement and sends to stdout
was a bit misleading.
Thanks for clarifying. (In turn, this begs the question, when is repr used for display instead of rich_repr?)
So the point really is that, at least for me personally, having rich_repr return graphics in the console (for any object, not only graphs) is very very undesirable.
On Wednesday, April 29, 2015 at 11:37:38 PM UTC-4, Martin R wrote:Oh, now that's an explanation! So the explanation in the third post on this thread,
displayhook: calls __repr__ on the value of the last statement and sends to stdoutwas a bit misleading.Well that was about plain Python...
Thanks for clarifying. (In turn, this begs the question, when is repr used for display instead of rich_repr?)_repr_ is used if an object does not implement _rich_repr_ or if _rich_repr_ does not return anything.
So the point really is that, at least for me personally, having rich_repr return graphics in the console (for any object, not only graphs) is very very undesirable.Presumably you find it desirable to display Graphics() objects (the return value of plot()) as picture, so there is that.
I'm only trying to understand. Yes, I assume it happens that someone is using sage as a python library and then possibly only wants repr.
So the point really is that, at least for me personally, having rich_repr return graphics in the console (for any object, not only graphs) is very very undesirable.Presumably you find it desirable to display Graphics() objects (the return value of plot()) as picture, so there is that.Of course. Hence, _rich_repr_ (or _repr_) should not return a Graphics object, right?.