[New-bugs-announce] [issue16669] Docstrings for namedtuple

Serhiy Storchaka report at bugs.python.org
Wed Dec 12 18:31:35 CET 2012

New submission from Serhiy Storchaka:

Here are two patches which implementation two different interface for same feature.

In first patch you can use *doc* and *field_docs* arguments to specify namedtuple class docstring and field docstrings. For example:

    Point = namedtuple('Point', 'x y',
                       doc='Point: 2-dimensional coordinate',
                       field_docs=['abscissa', 'ordinate'])

In second patch you can use *doc* argument to specify namedtuple class docstring and *field_names* argument can be a sequence of pairs: field name and field docstring. For example:

    Point = namedtuple('Point', [('x', 'absciss'), ('y', 'ordinate')],
                       doc='Point: 2-dimensional coordinate')

What approach is better?

Feel free to correct a documentation. I know that it need a correction.

components: Library (Lib)
files: namedtuple_docstrings_field_docs.patch
keywords: patch
messages: 177381
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Docstrings for namedtuple
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file28294/namedtuple_docstrings_field_docs.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list