The literal "*" in RestructuredText

I am considering this piece of code:

def ook(*args): """Some silly function. :param *args: Optional arguments. """ ... 

And as soon as I start Sphinx, I get an oxy-useful error:

 WARNING: Inline literal start-string without end-string. 

So, I tried param ``*``args , param :literal:'*' args and still get a warning.

How do I have the literal '*' in the restructured text?

+8
python restructuredtext python-sphinx
source share
2 answers

You can use a (somewhat ugly) backslash quote: \*

EDIT: As a (somewhat ugly) addition, if you are concerned about pylint's backslash warning, you can add r to the string literal: r""" ... docstring ... """ . It has been described in this pylint issue .

The presence of various word processing systems combines perfectly with each other and sometimes destroys aesthetics.

+10
source share

In a restructured text, you can use the .. code :: python directive.

http://docutils.sourceforge.net/docs/ref/rst/directives.html#code

This allows you to create a literal block of python code without any ugly '\' characters.

It looks like this:

 .. code:: python def ook(*args): """Some silly function. :param *args: Optional arguments. """ ... 

An example of using your function:

http://rst.ninjs.org/?n=c8ad07eaea190745755a6d80d37786e6&theme=basic

-one
source share

All Articles