Hacker News new | ask | show | jobs
by floatrock 2841 days ago
Truthiness!

Although this is a case where idiomatic python is different from idiomatic js.

In js:

  // same:
  !! ""   // false
  !! 0    // false
  !! 1    // true
  !! null // false  

  // different:
  !! {}  // true
  !! []  // true
while in python:

  # same:
  not not ""    # False
  not not 0     # False
  not not 1     # True
  not not None  # False
  
  # different:
  not not {}       # False
  not not []       # False
  not not tuple()  # False