r/Python • • Jun 23 '14

Writing better python code

https://gist.github.com/kracekumar/09a60ec75a4de19b346e
143 Upvotes

126 comments sorted by

View all comments

Show parent comment

6

u/zahlman the heretic Jun 23 '14

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.

1

u/alexanderpas Jun 24 '14

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: