-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
type attribute hides member of same name #35480
Comments
Allowing type attributes to replace member descriptors The use of __slots__ to define attributes allowed in an This change has useful advantages, but there is one The AttributeError raised in the following example >>> class B(object):
... a = 3
... __slots__ = ['a']
...
>>> b = B()
>>> b.a = 4
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'B' object attribute 'a' is read-only
>>> The member descriptor 'a' defined in __slots__ is An instance member defined by __slots__ can also be >>> class B(object):
... __slots__ = ['a']
...
>>> b = B()
>>> b.a = 4
>>> B.a = "hiding b.a"
>>> b.a
'hiding b.a'
>>> b.a = 5
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'B' object attribute 'a' is read-only
>>> |
Logged In: YES Changed category, and assigned to me in Guido's absence. |
Logged In: YES Reassigned to Guido. |
Logged In: YES Rejected. The patch would make it impossible to replace a __slots__ needs documentation. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: