[issue9391] Allow docstrings on dicts and named tuples outside of functions or classes.

Anthony Foglia report at bugs.python.org
Tue Jul 27 21:35:37 CEST 2010


Anthony Foglia <afoglia at gmail.com> added the comment:

I could see adding a doc parameter to the collections.namedtuple.  So that

---
>>> Point = collections.namedtuple("Point", ("x", "y"), doc="My point class")
>>> Point.__doc__
My point class
---

(Or it could keep the currently created docstring and append the new doc after an empty line.)

---
>>> Point = collections.namedtuple("Point", ("x", "y"), doc="My point class")
>>> Point.__doc__
Point(x, y)

My point class
---

That being said, I can't think of a strong use case.  If you care enough to add a docstring, you're probably making a type used repeatedly in the code.  In that case, you can just use the verbose parameter and paste the definition into your code.

I'm still in favor of it, simply because it would be a nice parameter to have, but I don't think it's important.

----------
nosy: +afoglia

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9391>
_______________________________________


More information about the Python-bugs-list mailing list