Y
Hacker News
new
|
ask
|
show
|
jobs
by
bobbylarrybobby
1229 days ago
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.
1 comments
scrollaway
1229 days ago
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.
link