Simon King wrote: > Hi Jason, > > On 22 Aug., 04:49, Jason Grout <jason-s...@creativetrax.com> wrote: >> Robert Bradshaw wrote: > [...] >>> One problem with this is that then one can't do "print M" and get what one >>> expects from a non-terminal line (e.g. inside a function, or anything but >>> the last line of a notebook cell). >> Can you elaborate? I'm not sure what you're trying to say---what would >> one expect? I thought Simon was saying that print M would lead a user >> to expect the matrix to be printed out. > > I think that means: Suppose you do want the output "29 x 29 dense > matrix over Integer Ring", but you are inside a function. If inside > the function you said "M", nothing would appear; if you said "print > M", then (according to my original suggestion) everything would be > shown, although this time you don't want it. You could do "print > M.__repr__()" inside the function, but that's not nice. >
Of course, you'd probably do repr(M) instead, which is more standard Python. But that's not something I'd expect someone to be able to guess naturally. And I don't think using repr would work anyway, since that is what is used for output when you just type M. print M prints M.__str__() M by itself prints out M.__repr__() > A configuration object would be a nice thing to have. And perhaps > *additionally* a display method that shows the matrix no matter what. > +1 on a function that does this, without having to set an attribute. +1 also on making sure that we don't keep adding more and more special-purpose display functions without making them have some sort of consistent scheme. +1 also on making the "display" function name somehow indicate how it is different than "show" or "prettyprint" or other similar-sounding functions. Jason -- Jason Grout --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---