Message310399
Only hash has the tri-state True/False/None behavior, defaulting to None. It's this way because None is the "do what's rational, based on eq and frozen" behavior. None of the other parameters work this way.
There's a long issue in the attrs repo that describes how they came to this conclusion: https://github.com/python-attrs/attrs/issues/136. I think it makes sense.
None of the dataclass parameters have a sentinel that would let me detect if the user provided a value or not. In the case of hash, I can't detect if they explicitly passed hash=None or just didn't provide a value. I've given this some thought, and couldn't come up with a use case for knowing this. For example, if init had a sentinel value of MISSING, what would the code ever do except start with:
if init is sentinel:
init = True
?
In addition to your list of dunder-control-parameters, there's frozen. It determines if instances are immutable (to the extent that they can be made immutable). |
|
Date |
User |
Action |
Args |
2018-01-22 07:37:56 | eric.smith | set | recipients:
+ eric.smith, larry, levkivskyi |
2018-01-22 07:37:56 | eric.smith | set | messageid: <1516606676.54.0.467229070634.issue32513@psf.upfronthosting.co.za> |
2018-01-22 07:37:56 | eric.smith | link | issue32513 messages |
2018-01-22 07:37:56 | eric.smith | create | |
|