[issue32513] dataclasses: make it easier to use user-supplied special methods
Larry Hastings
report at bugs.python.org
Mon Jan 22 03:58:14 EST 2018
Larry Hastings <larry at hastings.org> added the comment:
So if I understand correctly: the default value of the "repr" parameter is True.
Decision matrix: does dataclass insert a __repr__ into the class?
+-- row: argument passed in to decorator's repr parameter
|
|
v | yes | no | <--- columns: does the class have a __repr__?
-------+---------+---------+
True | ??? | yes |
-------+---------+---------+
False | no | no |
-------+---------+---------+
If the user specifies "repr=True", and also specifies their own __repr__ in the class, does dataclasses stomp on their __repr__ with its own? Does it throw an exception?
I still prefer the tri-state value here. In this version, the default value of the "repr" parameter would be None, and the decision matrix for inserting a __repr__ looks like this:
+-- row: argument passed in to decorator's repr parameter
|
|
v | yes | no | <--- columns: does the class have a __repr__?
-------+---------+---------+
True | raise | yes |
-------+---------+---------+
None | no | yes |
-------+---------+---------+
False | no | no |
-------+---------+---------+
But we've talked about using the tri-state default for all of these parameters before, and clearly you weren't swayed then, so I guess I've said my peace and I'll stop suggesting it.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32513>
_______________________________________
More information about the Python-bugs-list
mailing list