On Jun 10, 9:56 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
> On Tue, Jun 10, 2008 at 9:35 PM, John H Palmieri <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Jun 10, 7:12 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
> >> On Wed, May 28, 2008 at 2:03 PM, John H Palmieri <[EMAIL PROTECTED]> wrote:
>
> >> > In some code, I'd like to view or print an object depending on whether
> >> > in notebook mode with the "typeset" box checked or not.  Is this a
> >> > good way to do it?
>
> >> >            from sage.misc.misc import embedded
> >> >            from sage.misc.latex import pretty_print, view
> >> >            import sys
> >> >            if embedded() and sys.displayhook == pretty_print:
> >> >                view(x)
> >> >            else:
> >> >                print(x)
>
> >> I think that is the *only* way to do it.   I don't think it is a "good way"
> >> though.  It could be made much nicer by adding a single function somewhere,
> >> e.g., in misc/*/  that has the lines of code you wrote above in it,
> >> and has a meaningful name.    Then other code that needs to do the
> >> same thing will be easier to write and read.  What do you think?
>
> > Well, I didn't know if 'sys.displayhook == pretty_print' was the right
> > way to check for the typeset box.
>
> Well it works, and if we encapsulate it in a function (like you've done),
> then if we decide on a better way later it will be easy to change in only
> one place.
>
> > Anyway, here's a ticket (with a
> > patch):
>
> > <http://trac.sagemath.org/sage_trac/ticket/3396>
>
> Excellent.  If you add a doctest I'll give it a positive review :-)

I'm not sure how to add a doctest for this, since its behavior depends
on the situation, and since I don't know how to provide a doctest for
'view'.  Any suggestions?  (Besides, none of the other functions in
latex.py have doctests.  Well, maybe some of them do, but lots of them
don't.)

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

Reply via email to