re: Python 'is' vs '==' VIEW POST

re: Interesting. Thanks for the heads up. Except in some extremely rare, hack-y scenarios, you should only see is in the context of is None. You kn...

There are some corner cases when you would like to use the full comparison form. For example if None is used as an "no argument value was passed" flag:

def foo(a=None):
 if not a:
  print("No value provided")

it will print message for calls foo(), foo(0), foo(""), foo([]).

Yes, it's always best to test for the presence of None explicitly, rather than implicitly.

code of conduct - report abuse