Re: [Pyunit-interest] Confused about docstrings in unittest.py
Brought to you by:
purcell
|
From: Fred L. D. Jr. <fd...@ac...> - 2001-07-02 22:44:58
|
Patrick K. O'Brien writes:
> In the version of unittest.py that shipped with Python 2.1, why are some
> docstrings triple-quoted while others are single-quoted (and therefore not
> docstrings?). Here is an example, where failIf has only single quotes:
Docstring detection in Python is not based on the type of quoting;
they can be either single- or triple-quoted, "raw" or traditional, and
quoted with either single or double quotes. Check the __doc__
attributes of those methods and you'll see that the docstrings are
indeed in place.
The only requirement for docstrings is that they be string literals
(possibly composed of multiple concatenated parts) and the first
statement of their enclosing scope.
For example, this function has a legitimate docstring:
def func():
'This function ' "has" ''' a very
strangely '''\
r'quoted docstring.' \
r"""I would not recommend this."""
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Digital Creations
|