[issue9391] Allow docstrings on dicts and named tuples outside of functions or classes.
New submission from Anthony Long antl...@gmail.com: I would like to add docstrings to dicts and named tuples. Dicts can be used to hold many different kinds of information, and docstrings would help to shed light on what the dict does to others. Named tuples also should have docstrings, since they can also include information which can be explained it great detail within docstrings. -- components: Interpreter Core messages: 111711 nosy: antlong priority: normal severity: normal status: open title: Allow docstrings on dicts and named tuples outside of functions or classes. type: feature request versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9391 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9391] Allow docstrings on dicts and named tuples outside of functions or classes.
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: -1 on dicts You can simply subclass from dict to add docs. I think you can add docs to named tuples even without subclassing, but I need to check. -- nosy: +belopolsky versions: -Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9391 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9391] Allow docstrings on dicts and named tuples outside of functions or classes.
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Indeed, namedtuple auto-generates a doc-string and does not provide a way to customize it. It sounds reasonable to add a doc argument to namedtuple() function that would control __doc__ of the result. I am +0 on that. -- keywords: +easy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9391 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9391] Allow docstrings on dicts and named tuples outside of functions or classes.
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I'm also -1 on dicts -- just use a second dict to hold docstings. Can you elaborate on your proposal for named tuples? Keep in mind that the API is already somewhat complex and should not be expanded lightly. Also, the whole point of named tuples is to allow you to assign attribute names that are self-documenting (otherwise, you would just use t[0], t[1], etc). So, I'm not sure what the benefit would be for overriding the existing, auto-generated docstring which already gives some useful information (i.e. the position index of the attribute). -- assignee: - rhettinger nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9391 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9391] Allow docstrings on dicts and named tuples outside of functions or classes.
Anthony Foglia afog...@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 rep...@bugs.python.org http://bugs.python.org/issue9391 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9391] Allow docstrings on dicts and named tuples outside of functions or classes.
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Thanks for the idea and quick reply. In view of the discussion, I'm going to reject the feature request. The trade-off in added API complexity isn't worth the benefit especially given that subclassing already provides an option: class Point(namedtuple('Point', 'x y z')): Planet location with Sun as center point and x-axis passing through Alpha Centauri and distance measured in light seconds -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9391 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com