[New-bugs-announce] [issue40277] Improve repr for _tuplegetter objects

Raymond Hettinger report at bugs.python.org
Mon Apr 13 21:23:39 EDT 2020


New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:

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')

----------
assignee: rhettinger
components: Interpreter Core
keywords: easy (C)
messages: 366357
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Improve repr for _tuplegetter objects
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40277>
_______________________________________


More information about the New-bugs-announce mailing list