msg263733 - (view) |
Author: Paul Moore (paul.moore) *  |
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) *  |
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) *  |
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)  |
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) *  |
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) *  |
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) *  |
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) *  |
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)  |
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 |
|
|