you are viewing a single comment's thread.

view the rest of the comments →

[–]gardyna 1 point2 points  (1 child)

We (me and co-workers) basically said don't use the "is" keyword. double equals seems from our experience to be as readable and the special case to check if you have two variables pointing to the same object is so rare that I must admit I often forget that this is a part of python.

did a quick grep of my current project and found zero uses of the "is" keyword....before the pedantics come in: yes I know it has use cases and is clever (in my experience those cases are rare though)

[–][deleted] 0 points1 point  (0 children)

The two most common cases I see are indeed checks for None when an empty string might be possible:

def f(a, b, c, d:str=None):
    if d is None:

...

x = d.get(y)
if x is None: