Docstring

From Wikipedia, the free encyclopedia

In programming, a docstring is a string literal specified in source code. Docstrings can also be used as comments to document the purpose of a piece of code. Unlike conventional source code comments, or even specifically formatted comments like Javadoc documentation, docstrings are not stripped from the source tree when it is parsed, but are retained throughout the runtime of the program. This allows the program to inspect these comments at run time, for instance as an interactive help system, or as metadata.

Among languages that support docstrings are Python and Lisp.

In Lisp, docstrings are known as documentation strings. The Common Lisp standard states that a particular implementation may choose to discard docstrings whenever they want, for whatever reason. When they are kept, docstrings may be viewed (and changed) using the DOCUMENTATION function.

Contents

[edit] Python PEP 292

An addition to the Python language as of version 2.4, PEP 292 Template Strings provide an extended facility for specifying string literals in python source code. Such template strings support variable interpolation and substitution, and may be used in combination with Python docstring syntax.

[edit] Tools using docstrings

[edit] See also

[edit] External links