On Fri, Aug 21, 2009 at 5:34 PM, Robert Bradshaw < rober...@math.washington.edu> wrote:
> On Fri, 21 Aug 2009, Simon King wrote: > > > > > On 22 Aug., 00:57, William Stein <wst...@gmail.com> wrote: > >> On Fri, Aug 21, 2009 at 3:18 PM, Simon King <simon.k...@nuigalway.ie> > wrote: > > [...] > >>> sage: print M.str() > >>> but there might be nicer (and more intuitive!) ways. > >> > >> I think that is the only way. I can't think of any nicer way. Any idea > >> what it *should* be? > > > > sage: M > > 29 x 29 dense matrix over Integer Ring > > sage: print M > > [ 100 201 892 ... > > > > In other words: If the user types a *command* to display M, then one > > can assume that (s)he really wants to see something (here: content of > > M). But if M is addressed without a command, it might be better to not > > confront the user with lengthy data. > > > > It's just a version of "explicit is better than implicit" - namely > > "using a command means more than not using a command". > > Therefore I believe that __repr__() should not necessarily coincide > > with __str__(). > > 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). > > > Why do I think that "print M.str()" is not intuitive? Since it is > > *two* commands, str() and print (without print it looks ugly). > > So, better might be a method with a descriptive name such as > > "prettyprint", "display", "print_all", etc. that returns None (rather > > than a string) but prints M to stdout. > > > > One problem in that approach is that there is already show() and plot > > () and so on. So, if there are too many display-related methods, it > > might be difficult to tell them apart. Perhaps: show() uses graphic, > > display() uses ascii art. > > +1 to somethign like display(). > > Really, there should be a way to set a threshold for something like this. > I like Robert's suggestion. How about make the compressed display helpful: sage: M 29 x 29 dense matrix over Integer Ring (use config.matrix_print to print larger matrices) sage: config.matrix_print? tells me how to use it... sage: config.matrix_print(50) sage: M [...] The config object could allow for a wide range of print configuration and other options. -- William --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---