-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement
Description
Currently, can make an assignment to an instance's __dict__ attribute but the value must be an actual dict. It should allow frozendict as well.
This would be useful for making immutable instances without the awkward work arounds used in frozen dataclasses.
>>> class Point:
... def __init__(self, x, y):
... self.__dict__ = frozendict(x=x, y=y)
...
>>> p = Point(10, 20)
Traceback (most recent call last):
File "<pyshell#53>", line 1, in <module>
p = Point(10, 20)
File "<pyshell#52>", line 3, in __init__
self.__dict__ = frozendict(x=x, y=y)
TypeError: __dict__ must be set to a dictionary, not a 'frozendict'Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement