I agree with the choice of _sage_init_.  By default this can return
self._repr_(), but should be overridden in cases like matrix.
David

On Wed, Mar 5, 2008 at 1:32 AM, Robert Bradshaw <
[EMAIL PROTECTED]> wrote:

>
> _sage_init_ sounds like the right solution. The problem is that for
> many objects, printing all the information that would make them
> reproducible is really ugly. For example, if I have
>
> [1 2]
> [3 4]
>
> Is this over the integers, or the rationals, or the integers mod 17?
> Or perhaps it's a symbolic matrix, or over a polynomial ring of a
> finite field of a particular modulus. Of course, this could be
> incorporated into the representation, but one doesn't usually want to
> see it unless it is explicitly asked for.
>
> For this reason, most of the focus has been on having good pickling/
> unpicking support.
>
> - Robert
>
>
> On Mar 4, 2008, at 10:59 AM, Jason Grout wrote:
>
> > This morning I tried to copy a matrix output, edit it, and create a
> > new
> > matrix.  It was frustrating because there seemed to be no way to
> > easily
> > cut and paste output into input.  This afternoon a person I was
> > showing
> > Sage to also had the same concern.
> >
> > There has been discussion before on the python convention of str
> > versus
> > repr, especially in light of the python docs:
> >
> > "repr(object)
> >      Return a string containing a printable representation of an
> > object.
> > This is the same value yielded by conversions (reverse quotes). It is
> > sometimes useful to be able to access this operation as an ordinary
> > function. For many types, this function makes an attempt to return a
> > string that would yield an object with the same value when passed to
> > eval()."
> >
> > For matrices, repr() and str() yield the same output which is pretty
> > much useless to try to cut and paste back into input.
> >
> > Please let me know if
> >
> >   * I should not implement repr for matrices and graphs in
> > accordance to
> > the python docs.
> >
> >   * There is another function, like the input_form that mabshoff
> > suggested on 2386, which could give a code-like representation of an
> > object if possible?
> >
> >
> > Thanks,
> >
> > Jason
> >
> >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to