@pythonnotes
python notes
3 years
When you set default value to field using a mutable object like list or dictionary, a ValueError will come out. Use default_factory instead. #Python
1
0
0

Replies

@pythonnotes
python notes
3 years
Because dataclasses just use normal Python class creation so two instances of class ABC share the same class variable a, which might not be a desired behavior in a dataclass, so it raises a ValueError to avoid this.
0
0
1