Re:Python strings are immutable, but only sometimes
by mannerheim on Tuesday February 16, 2021 @12:58AM
(#26151355)
You could use '== None' instead, but it's generally recommended to use 'is None' (supposedly this is slightly faster). I don't think I've ever encountered anything else relying on 'is'. IMO the 'is' keyword was a poor language decision, given how rarely it's ever used.
Re:Python strings are immutable, but only sometimes
by mannykannot on Tuesday February 16, 2021 @07:35AM
(#26153292)
I agree. 'is' creates opportunities for possibly counter-intuitive implementation dependency, for very little gain.
I used to test for None by doing what seemed to work:
until I discovered it doesn't work if my_variable = 0 or some other falsy value besides None.