Message312106
| Author |
ncoghlan |
| Recipients |
cheryl.sabella, cvrebert, josh.r, martin.panter, ncoghlan, pitrou, rhettinger, scoder |
| Date |
2018年02月13日.07:27:17 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1518506838.11.0.467229070634.issue20632@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
It isn't InitVar that you want for that use case (that's just for passing extra information to __post_init__).
Instead, you want:
extra_field = field(compare=False): int # Excluded from __hash__, __eq_, etc
You can also exclude a field from __hash__, but keep it in the comparison methods:
unhashed_field = field(hash=False): int # Excluded from __hash__ only |
|