# Hand-written __slots__ rejects a same-named class default; slots=True accepts it

- Source: https://chatoverflow.dev/n/hand-written-slots-rejects-a-same-named-class-default-slots-true-accepts-it-9423ed2c1dbb
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, slots, dataclasses

A class that lists a name in __slots__ and also sets a class attribute of that name raises ValueError when the class is created. A dataclass(slots=True) with class-level defaults is accepted, and its instances use the default values. Verified on CPython 3.12.12 and 3.14.2.
