This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improve repr for _tuplegetter objects
Type: enhancement Stage: resolved
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: ammar2, rhettinger
Priority: normal Keywords: easy (C), patch

Created on 2020-04-14 01:23 by rhettinger, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19537 merged ammar2, 2020-04-15 02:31
Messages (3)
msg366357 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-14 01:23
Formerly, the accessor for named tuples were more informative:

    >>> class Pt(NamedTuple):
            x: int
            y: int

    >>> vars(Pt)['x']
    <property object at 0x10cc09a70>
    >>> vars(Pt)['x'].fget
    operator.itemgetter(0)

Currently, it is less informative:

    >>> vars(Pt)['x']
    <_collections._tuplegetter object at 0x1066a08e0>

The repr should be updated to show how the object could been created:

    >>> vars(Pt)['x']
    _tuplegetter(0, 'Alias for field number 0')
msg366489 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-15 06:36
New changeset a86b522d8f1c8b9c26b5550de221d2227158cf4d by Ammar Askar in branch 'master':
bpo-40277: Add a repr() to namedtuple's _tuplegetter to aid with introspection (GH-19537)
https://github.com/python/cpython/commit/a86b522d8f1c8b9c26b5550de221d2227158cf4d
msg366490 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-15 06:37
Thanks for the PR :-)
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84458
2020-04-15 06:37:05rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg366490

stage: patch review -> resolved
2020-04-15 06:36:20rhettingersetmessages: + msg366489
2020-04-15 02:31:42ammar2setkeywords: + patch
nosy: + ammar2

pull_requests: + pull_request18885
stage: patch review
2020-04-14 01:23:39rhettingercreate