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

Improve repr for _tuplegetter objects #84458

Closed
rhettinger opened this issue Apr 14, 2020 · 3 comments
Closed

Improve repr for _tuplegetter objects #84458

rhettinger opened this issue Apr 14, 2020 · 3 comments
Assignees
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@rhettinger
Copy link
Contributor

BPO 40277
Nosy @rhettinger, @ammaraskar
PRs
  • bpo-40277: Add a repr() to namedtuple's _tuplegetter to aid with introspection #19537
  • 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 = 'https://github.com/rhettinger'
    closed_at = <Date 2020-04-15.06:37:05.093>
    created_at = <Date 2020-04-14.01:23:39.288>
    labels = ['interpreter-core', 'easy', 'type-feature']
    title = 'Improve repr for _tuplegetter objects'
    updated_at = <Date 2020-04-15.06:37:05.093>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2020-04-15.06:37:05.093>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2020-04-15.06:37:05.093>
    closer = 'rhettinger'
    components = ['Interpreter Core']
    creation = <Date 2020-04-14.01:23:39.288>
    creator = 'rhettinger'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40277
    keywords = ['patch', 'easy (C)']
    message_count = 3.0
    messages = ['366357', '366489', '366490']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'ammar2']
    pr_nums = ['19537']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40277'
    versions = []

    @rhettinger
    Copy link
    Contributor Author

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

    @rhettinger rhettinger self-assigned this Apr 14, 2020
    @rhettinger rhettinger added interpreter-core (Objects, Python, Grammar, and Parser dirs) easy type-feature A feature request or enhancement labels Apr 14, 2020
    @rhettinger rhettinger self-assigned this Apr 14, 2020
    @rhettinger rhettinger added interpreter-core (Objects, Python, Grammar, and Parser dirs) easy type-feature A feature request or enhancement labels Apr 14, 2020
    @rhettinger
    Copy link
    Contributor Author

    New changeset a86b522 by Ammar Askar in branch 'master':
    bpo-40277: Add a repr() to namedtuple's _tuplegetter to aid with introspection (GH-19537)
    a86b522

    @rhettinger
    Copy link
    Contributor Author

    Thanks for the PR :-)

    @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
    easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant