This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tefra
Recipients tefra
Date 2021-07-15.19:06:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626375963.06.0.364448585924.issue44649@roundup.psfhosted.org>
In-reply-to
Content
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+
History
Date User Action Args
2021-07-15 19:06:03tefrasetrecipients: + tefra
2021-07-15 19:06:03tefrasetmessageid: <1626375963.06.0.364448585924.issue44649@roundup.psfhosted.org>
2021-07-15 19:06:03tefralinkissue44649 messages
2021-07-15 19:06:03tefracreate