GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `__name__` to property · Issue #101860 · python/cpython

Add __name__ to property #101860

New issue
Copy link
New issue
Copy link
Closed
Closed
Add __name__ to property#101860
Copy link
Labels
3.13only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@eltoder
eltoder
opened on Feb 13, 2023
Issue body actions
class C:
    @property
    def foo(self):
        return 1

assert C.foo.__name__ == "foo"

It would be very handy if this worked, so properties can be introspected the same way as functions, classmethods, etc. Name can be simply taken from fget the same way this is done for __isabstractmethod__.

Linked PRs

  • gh-101860: Expose __name__ on property #101876
  • gh-101860: document property.__name__ #123399
  • [3.13] gh-101860: document property.__name__ (GH-123399) #123428

Activity

  1. eltoder
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Feb 13, 2023
  2. arhadthedev
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Feb 13, 2023
  3. sobolevn commented on Feb 13, 2023

    @sobolevn
    sobolevn
    on Feb 13, 2023
    Member
    More actions

    What about this case?

    >>> def getter(o):
    ...     return 42
    ... 
    >>> class Some:
    ...    number = property(getter)
    ... 
    >>> Some().number
    42

    Should it be 'getter'?

  4. TeamSpen210 commented on Feb 13, 2023

    @TeamSpen210
    TeamSpen210
    on Feb 13, 2023
    More actions

    Actually, property already defines __set_name__(), storing the name internally for use in formatting AttributeErrors. That's called during class creation, so it'll be accurate regardless where the callable comes from. All that's needed is for that to be exposed. This was added in #71981, but it was kept private to avoid expanding the API since a need wasn't specified.

  5. eltoder commented on Feb 13, 2023

    @eltoder
    eltoder
    on Feb 13, 2023
    ContributorAuthor
    More actions

    @TeamSpen210 Nice find! I think the API expansion comments were about adding name as an argument to property constructor. Adding __name__ as a read-only attribute for introspection seems very much in the spirit of python.

  6. eltoder
    added 4 commits that reference this issue on Feb 13, 2023

    pythongh-101860: Expose __name__ on property

    9ef17ae

    pythongh-101860: Expose __name__ on property

    e5ce6b7

    pythongh-101860: Expose __name__ on property

    05db108

    pythongh-101860: Expose __name__ on property

    9c956c7
  7. eltoder
    added a commit that references this issue on Feb 17, 2024

    pythongh-101860: Expose __name__ on property

    8ec1251
  8. serhiy-storchaka
    added a commit that references this issue on Feb 20, 2024

    gh-101860: Expose __name__ on property (GH-101876)

    c0b0c2f
  9. serhiy-storchaka
    closed this as completedon Feb 20, 2024
  10. woodruffw
    added a commit that references this issue on Mar 4, 2024

    pythongh-101860: Expose __name__ on property (pythonGH-101876)

    f7dedb5
  11. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythongh-101860: Expose __name__ on property (pythonGH-101876)

    794df41
  12. JelleZijlstra commented on May 24, 2024

    @JelleZijlstra
    JelleZijlstra
    on May 24, 2024
    Member
    More actions

    This is a change to a builtin and likely has an impact on some introspection tools, so it should be mentioned in the What's New for 3.13.

    Reacted by Serhiy Storchaka, sLeae and Miro Hrončok
    Reacted by sLeae
    Reacted by sLeae
  13. JelleZijlstra
    reopened this on May 24, 2024
  14. JelleZijlstra
    added
    deferred-blocker
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    3.13only security fixesonly security fixes
    on May 24, 2024
  15. ezio-melotti
    added this to Release and Deferred blockers 🚫on May 24, 2024
  16. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on May 24, 2024
  17. encukou
    added a commit that references this issue on Aug 28, 2024

    gh-101860: document `property.__name__` (GH-123399)

    40fff90
  18. miss-islington
    added a commit that references this issue on Aug 28, 2024

    pythongh-101860: document `property.__name__` (pythonGH-123399)

    55ad0e5
  19. JelleZijlstra
    added a commit that references this issue on Aug 29, 2024

    [3.13] gh-101860: document `property.__name__` (GH-123399) (#123428)

    eec25e5
  20. picnixz commented on Aug 30, 2024

    @picnixz
    picnixz
    on Aug 30, 2024
    Member
    More actions

    Closing since the feature is now documented in 3.13 and 3.14.

  21. picnixz
    closed this as completedon Aug 30, 2024
  22. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on Aug 30, 2024
  23. picnixz
    removed
    deferred-blocker
    on Aug 30, 2024
  24. LukasWoodtli
    added a commit that references this issue on Jan 22, 2025

    pythongh-101860: Expose __name__ on property (pythonGH-101876)

    b7abd7a
  25. luhn
    added a commit that references this issue on Jun 30, 2025

    Fix util tests in Python 3.12+

    4d139f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Release and Deferred blockers 🚫
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.