On May 9, 11:48 am, "William Stein" <[EMAIL PROTECTED]> wrote:
> On Fri, May 9, 2008 at 11:41 AM, John H Palmieri <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > How do you put a backslash in a documentation string for a function?
>
> > def function(x, str=''):
> > r"""
> > The string str could be a LaTeX command like '\vspace{3em}'.
> > """
> > return None
>
> > If I type 'function?', I get
>
> > The string str could be a LaTeX command like 'vspace{3em}'.
>
> > Note that the backslash is not printed, but I want it to be. I've
> > tried various permutations with \ vs. \\, and with r""" vs. """ at the
> > beginning of the doc string, but I have had no luck.\
>
> The backslash is there. Try
>
> function.__doc__
>
> to see it. The "problem" is that docstrings are run through
> a detex'ing procedure before being displayed. I don't remember
> is there is a way to make that detexing show backslashes.
>
> The detex function is in devel/sage/sage/misc/sagedoc.py.
> Looking at it we see that if you do this instead you'll see the backslash:
>
> def function(x, str=''):
> r"""nodetex
> The string str could be a LaTeX command like '\vspace{3em}'.
> """
> return None
This sort of works: I get
nodetex
The string str could be a LaTeX command like '\vspace{3em}'.
That 'nodetex' at the beginning is ugly, though, don't you think?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---