Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are these tags @ivar @param and @type in python docstring?

The ampoule project uses some tags in docstring, like the javadoc ones.

For example from pool.py line 86:

def start(self, ampChild=None):
    """
    Starts the ProcessPool with a given child protocol.

    @param ampChild: a L{ampoule.child.AMPChild} subclass.
    @type ampChild: L{ampoule.child.AMPChild} subclass
    """

What are these tags, which tool uses it.

like image 301
Andrea Francia Avatar asked Dec 18 '08 21:12

Andrea Francia


People also ask

What is docstrings in Python give an example?

A Python docstring is a string used to document a Python module, class, function or method, so programmers can understand what it does without having to read the details of the implementation. Also, it is a common practice to generate online (html) documentation automatically from docstrings.

What should be in a docstring Python?

The docstring for a function or method should summarize its behavior and document its arguments, return value(s), side effects, exceptions raised, and restrictions on when it can be called (all if applicable). Optional arguments should be indicated.

What is the difference between a __ docstring __ and a comment?

Comments are great for leaving notes for people working on your program. Docstrings provide documentation about functions, classes, and modules. Use docstrings to teach other developers how to use your program.


1 Answers

Just for fun I'll note that the Python standard library is using Sphinx/reStructuredText, whose info field lists are similar.

def start(self, ampChild=None):
    """Starts the ProcessPool with a given child protocol.

    :param ampChild: a :class:`ampoule.child.AMPChild` subclass.
    :type ampChild: :class:`ampoule.child.AMPChild` subclass
    """
like image 135
cdleary Avatar answered Oct 21 '22 20:10

cdleary