Issue 26805: Refer to types.SimpleNamespace in namedtuple documentation (original) (raw)

Created on 2016-04-19 12:25 by paul.moore, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
collections.patch vstinner,2016-04-19 13:44 review
Messages (9)
msg263733 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2016-04-19 12:25
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. """
msg263737 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-04-19 13:44
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)
msg263740 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2016-04-19 14:02
Thanks Victor. I'll sort this out this evening when I get to my PC with access to the CPython repo.
msg263757 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-19 18:20
New changeset c3232d1d8ca0 by Paul Moore in branch 'default': Mention types.SimpleNamespace in collections.namedtuple doc https://hg.python.org/cpython/rev/c3232d1d8ca0
msg263759 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-04-19 19:22
types.SimpleNamespace is also available on Python 3.5, you may also modify Python 3.5 doc.
msg263761 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2016-04-19 19:54
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"...)
msg263763 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-04-19 20:14
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
msg263769 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-04-19 20:36
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)
msg263779 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-19 22:00
New changeset 3115b6ce1006 by Paul Moore in branch '3.5': Mention types.SimpleNamespace in collections.namedtuple doc https://hg.python.org/cpython/rev/3115b6ce1006
History
Date User Action Args
2022-04-11 14:58:29 admin set github: 70992
2016-04-19 22:00:01 python-dev set messages: +
2016-04-19 20:36:16 berker.peksag set nosy: + berker.peksagmessages: +
2016-04-19 20:14:07 vstinner set messages: +
2016-04-19 19:54:44 paul.moore set messages: +
2016-04-19 19:22:09 vstinner set messages: +
2016-04-19 18:22:02 paul.moore set status: open -> closedresolution: fixedstage: needs patch -> resolved
2016-04-19 18:20:11 python-dev set nosy: + python-devmessages: +
2016-04-19 14:02:06 paul.moore set messages: +
2016-04-19 13:44:09 vstinner set files: + collections.patchnosy: + vstinnermessages: + keywords: + patch
2016-04-19 12:36:38 berker.peksag set keywords: + easystage: needs patchversions: + Python 3.5
2016-04-19 12:29:00 Rosuav set nosy: + Rosuav
2016-04-19 12:25:44 paul.moore create