New submission from Christodoulos Tsoulloftas <ch...@komposta.net>: I am trying the new slots directive but I get an AttributeError when I try to access a field with init=False
>>> from dataclasses import dataclass, field >>> >>> @dataclass(slots=True) ... class Example: ... a: str ... b: str = field(default="b", init=False) ... >>> obj = Example("a") >>> obj.__slots__ ('a', 'b') >>> obj. obj.a obj.b >>> obj.a 'a' >>> obj.b Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: b. Did you mean: 'b'? >>> ❯ python --version Python 3.10.0b4+ ---------- components: Library (Lib) messages: 397575 nosy: tefra priority: normal severity: normal status: open title: dataclasses slots with init=False field raises AttributeException type: behavior versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44649> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com