Message397575
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+ |
|
Date |
User |
Action |
Args |
2021-07-15 19:06:03 | tefra | set | recipients:
+ tefra |
2021-07-15 19:06:03 | tefra | set | messageid: <1626375963.06.0.364448585924.issue44649@roundup.psfhosted.org> |
2021-07-15 19:06:03 | tefra | link | issue44649 messages |
2021-07-15 19:06:03 | tefra | create | |
|