News for hackers. Stuff that matters.
Re:Python best practices by sah on Wednesday July 09, 2008 @12:07AM (#240768)
There's a reason why "if x is None" is idiomatic when "if not x" is shorter:

  >>> x = ''
  >>> if x is None:
  ...   print 'x is None'
  ...
  >>> if not x:
  ...   print 'x is empty'
  ...
  x is empty
Re:Python best practices by yogipatel on Wednesday July 09, 2008 @03:56AM (#240901)
Good point. I was only thinking of sequence types, and failed to see that it would break with strings. I also somehow forgot to include "not" in the if statements! Pretty sad for a first post...