Re:Google Python Style Guide
by bobbylarrybobby on Saturday February 11, 2023 @12:11PM
(#34754142)
Ideally you'd use `if len(x) == 0`, which handles lists but also list-like things like tuples, while not letting None and False through.
[ Parent
| on HN ]
Re:Google Python Style Guide
by scrollaway on Saturday February 11, 2023 @01:42PM
(#34754974)
len will count the object whereas “not” will only check for truthiness. This can matter in cases where counting takes significantly longer; for example, a sql query set.