Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

None and How to Test for It

Comments & Discussion

Bart Willems on July 28, 2020

I still struggle with “because None is a singleton you have to use is, and what I found it this:

In most cases == and is return the same result, but it’s possible to have objects where the equality operator is overriden and might give a wrong result (simplified example):

class Foo:
  def __eq__(self, other):
    return True

x = Foo()
x == None # True
x is None # False

Because the equality operator can give you the wrong answer you should use is, but because None is a singleton it might lead you to think you can use == as well. Which will work in many cases—and then you’ll spend hours figuring out why your code doesn’t work.

Become a Member to join the conversation.