Thursday 12 July 2018

Python Documentation String

Cited from the book "Python How to Program"

If a class contains a optional documentation string -- a string that describes the class, the string must appear in the line or lines following the class header. A user can view a class’s documentation string by executing the following statement.

print ClassName.__doc__

Modules, methods and functions also may specify a documentation string.

By convention, docstrings are triple-quoted strings. This convention allows the class author
to expand a program’s documentation (e.g., by adding several more lines) without having to
change the quote style.


No comments:

Post a Comment