News for hackers. Stuff that matters.
Re:How to write X in both Python 3 and JavaScript by floatrock on Friday September 14, 2018 @01:01PM (#17988888)
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

There are no comments on this comment yet.