Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
bobbylarrybobby
on Feb 11, 2023
|
parent
|
context
|
favorite
| on:
Google Python Style Guide
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.
scrollaway
on Feb 11, 2023
[–]
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.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: