Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Provide name suggestions for failed attribute deletions #130425

Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement
@Pranjal095

Description

@Pranjal095

Feature or enhancement

Proposal:

This was initially mentioned as a comment inissue #130399.

classA:passa=A()a.abcde=1dela.abcdf# typo

Current Output

Traceback (mostrecentcalllast):File"<python-input-0>",line6,in<module>dela.abcdf# typo^^^^^^^AttributeError:'A'objecthasnoattribute'abcdf'

CPython provides name suggestions when an attribute lookup (obj.attr) fails, but it does not provide similar suggestions when an attribute deletion (del obj.attr) fails. This brings about an inconsistency with regards to the developer experience offered by the language.

Expected Output

Traceback (mostrecentcalllast):File"<python-input-0>",line6,in<module>dela.abcdf# typo^^^^^^^AttributeError:'A'objecthasnoattribute'abcdf'.Didyoumean:'abcde'?

Advantages

  • Helps users quickly identify typos in attribute deletions.
  • CPython already provides name suggestions for failed attribute lookups (obj.attr), so deletions (del obj.attr) should behave similarly.
  • Suggestions are only generated when an attribute deletion fails, and hence has a minimal performance impact.

Note
CPython version - CPython main branch
Operating system - Ubuntu 22.04

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp