Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refer to types.SimpleNamespace in namedtuple documentation #70992

Closed
pfmoore opened this issue Apr 19, 2016 · 9 comments
Closed

Refer to types.SimpleNamespace in namedtuple documentation #70992

pfmoore opened this issue Apr 19, 2016 · 9 comments
Labels
docs Documentation in the Doc dir easy type-feature A feature request or enhancement

Comments

@pfmoore
Copy link
Member

pfmoore commented Apr 19, 2016

BPO 26805
Nosy @pfmoore, @vstinner, @Rosuav, @berkerpeksag
Files
  • collections.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-04-19.18:22:02.134>
    created_at = <Date 2016-04-19.12:25:44.423>
    labels = ['easy', 'type-feature', 'docs']
    title = 'Refer to types.SimpleNamespace in namedtuple documentation'
    updated_at = <Date 2016-04-19.22:00:01.130>
    user = 'https://github.com/pfmoore'

    bugs.python.org fields:

    activity = <Date 2016-04-19.22:00:01.130>
    actor = 'python-dev'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2016-04-19.18:22:02.134>
    closer = 'paul.moore'
    components = ['Documentation']
    creation = <Date 2016-04-19.12:25:44.423>
    creator = 'paul.moore'
    dependencies = []
    files = ['42520']
    hgrepos = []
    issue_num = 26805
    keywords = ['patch', 'easy']
    message_count = 9.0
    messages = ['263733', '263737', '263740', '263757', '263759', '263761', '263763', '263769', '263779']
    nosy_count = 6.0
    nosy_names = ['paul.moore', 'vstinner', 'docs@python', 'python-dev', 'Rosuav', 'berker.peksag']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue26805'
    versions = ['Python 3.5', 'Python 3.6']

    @pfmoore
    Copy link
    Member Author

    pfmoore commented Apr 19, 2016

    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.
    """

    @pfmoore pfmoore added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Apr 19, 2016
    @vstinner
    Copy link
    Member

    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)

    @pfmoore
    Copy link
    Member Author

    pfmoore commented Apr 19, 2016

    Thanks Victor. I'll sort this out this evening when I get to my PC with access to the CPython repo.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 19, 2016

    New changeset c3232d1d8ca0 by Paul Moore in branch 'default':
    Mention types.SimpleNamespace in collections.namedtuple doc
    https://hg.python.org/cpython/rev/c3232d1d8ca0

    @pfmoore pfmoore closed this as completed Apr 19, 2016
    @vstinner
    Copy link
    Member

    types.SimpleNamespace is also available on Python 3.5, you may also modify Python 3.5 doc.

    @pfmoore
    Copy link
    Member Author

    pfmoore commented Apr 19, 2016

    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"...)

    @vstinner
    Copy link
    Member

    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

    @berkerpeksag
    Copy link
    Member

    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)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 19, 2016

    New changeset 3115b6ce1006 by Paul Moore in branch '3.5':
    Mention types.SimpleNamespace in collections.namedtuple doc
    https://hg.python.org/cpython/rev/3115b6ce1006

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir easy type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants