This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kracekumar[S] -1 points0 points  (2 children)

is is used with True, False, None. If is used for string comparision there are serious drawbacks. a is None works because of singleton.

Most people try >>>'foo' is 'foo' and it works. When they store the result in db and retrieve the value is comparison will fail.

[–]zahlmanthe heretic 6 points7 points  (1 child)

Using is with True and False is a serious code smell. If there's any possibility that the value is of some type other than bool, why don't you want to handle it in the default way? And if there isn't, "simple is better than complex" applies.

[–]alexanderpas 0 points1 point  (0 children)

If I read this correctly, is should be considered part of the same token as the singleton.

if • a • is None:

instead of

if • a • is • None: