Hi,

I'm writing some code where I sometimes give a function mathematical
objects, and want it to run latex() on them -- and sometimes I give it a
string of LaTeX code and want the function to leave it alone.

I can typecheck the inputs, but I understand that's not Pythonic. The
problem seems to be that you can run latex() on a LatexExpr -- but
that's basically never what you want.

Here's my idea: running latex() on a LatexExpr object should raise a
ValueError. Then you can do:

    try:
        foo = latex(bar)
    except ValueError:
        foo = bar

which seems more Pythonic than

    if isistance(bar, basestring):
        foo = bar
    else:
        foo = latex(bar)

If you really want to do latex() to a LatexExpr, just run str() on it
first.

Perhaps a simpler alternative would be that latex() on a LatexExpr
doesn't do anything -- it's just the identity.

Thoughts?

Dan

-- 
---  Dan Drake
-----  www.math.wisc.edu/~ddrake/
-------

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to