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?

 -- 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