DEV Community

Discussion on: Python 'is' vs '=='

Collapse
 
ardraeiss profile image
Mikhail Merzlyutin

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([]).

Thread Thread
 
codemouse92 profile image
Jason C. McDonald

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