News for hackers. Stuff that matters.
Re:Python strings are immutable, but only sometimes by exporectomy on Monday February 15, 2021 @09:15PM (#26150174)
But this is using the seemingly harmless keyword "is" that's you're supposed to use sometimes. A programmer could stumble upon one of these statements and think it's going to work reliably after it works the first time.

I used to test for None by doing what seemed to work:

  if my_variable:
    do something
until I discovered it doesn't work if my_variable = 0 or some other falsy value besides None.
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.