[issue26805] Refer to types.SimpleNamespace in namedtuple documentation
New submission from Paul Moore: People often look towards collections.namedtuple when all they actually want is "named attribute" access to a collection of values, without needing a tuple subclass, or positional access. In these cases, types.SimpleNamespace may be a better fit. I suggest adding the following pointer to the top of the namedtuple documentation: """ For simple uses, where the only requirement is to be able to refer to a set of values by name using attribute-style access, the :ref:`types.SimpleNamespace` type may be a suitable alternative to using a namedtuple. """ ---------- assignee: docs@python components: Documentation messages: 263733 nosy: docs@python, paul.moore priority: normal severity: normal status: open title: Refer to types.SimpleNamespace in namedtuple documentation type: enhancement versions: Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Changes by Chris Angelico <rosuav@gmail.com>: ---------- nosy: +Rosuav _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Changes by Berker Peksag <berker.peksag@gmail.com>: ---------- keywords: +easy stage: -> needs patch versions: +Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
STINNER Victor added the comment: LGTM. I was going to push your sugestion when I saw that you are allowed to push yourself. See my attached patch: * I fixed :ref:`types.SimpleNamespace` => you have to use :class:`...` * I replaced "may be" with "can be" (I'm not confortable with "may", but it's up to you) ---------- keywords: +patch nosy: +haypo Added file: http://bugs.python.org/file42520/collections.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Paul Moore added the comment: Thanks Victor. I'll sort this out this evening when I get to my PC with access to the CPython repo. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Roundup Robot added the comment: New changeset c3232d1d8ca0 by Paul Moore in branch 'default': Mention types.SimpleNamespace in collections.namedtuple doc https://hg.python.org/cpython/rev/c3232d1d8ca0 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Changes by Paul Moore <p.f.moore@gmail.com>: ---------- resolution: -> fixed stage: needs patch -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
STINNER Victor added the comment: types.SimpleNamespace is also available on Python 3.5, you may also modify Python 3.5 doc. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Paul Moore added the comment: Ah, thanks. I probably did the commit the wrong way round in that case, as I committed to tip. How should I do the commit into 3.5? (I'm also somewhat confused by the fact that hg describes the 3.5 branch as "inactive"...) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
STINNER Victor added the comment: I don't know what "inactive" means in Mercurial. Python 3.5 is actively developed (maintained): https://docs.python.org/devguide/#status-of-python-branches
How should I do the commit into 3.5?
Update to 3.5 (hg up 3.5), transplant your change (hg transplant c3232d1d8ca0). Fix if needed. I don't recall if you need to commit or not (commit if you get the patch as local changes). Then update to default (hg update default), and merge 3.5 (hg merge 3.5). Commit. https://docs.python.org/devguide/devcycle.html#branches ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Berker Peksag added the comment: Or if you don't want to use any hg extension: hg update 3.5 hg import --no-c http://bugs.python.org/file42520/collections.patch hg commit hg update default hg merge 3.5 hg revert -ar default hg resolve -am hg commit (Null merge (hg merge 3.5 and later) is step documented at https://docs.python.org/devguide/faq.html?#how-do-i-make-a-null-merge) ---------- nosy: +berker.peksag _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
Roundup Robot added the comment: New changeset 3115b6ce1006 by Paul Moore in branch '3.5': Mention types.SimpleNamespace in collections.namedtuple doc https://hg.python.org/cpython/rev/3115b6ce1006 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26805> _______________________________________
participants (5)
-
Berker Peksag
-
Chris Angelico
-
Paul Moore
-
Roundup Robot
-
STINNER Victor