Re:WTF Python: Exploring and understanding Python through su...
by dragonwriter on Thursday February 11, 2021 @04:09AM
(#26099652)
> Yet the same be benefits of explicit None checks can be attained by writing "== None"
If you are going to do that's you should probably do a backwards comparison (`None==x`), otherwise you are calling x.__eq__(None), which probably won't be surprising in result if you have constrained things with sane typing, but still could be more expensive than `x is None`.
If you are going to do that's you should probably do a backwards comparison (`None==x`), otherwise you are calling x.__eq__(None), which probably won't be surprising in result if you have constrained things with sane typing, but still could be more expensive than `x is None`.
`x is None` reads a lot better though.