I’d like opinions on the most idiomatic way to write a function that returns True if an object is truthy, and False otherwise. For example:
is_truthy(True) # True
is_truthy(False) # False
is_truthy(123) # True
is_truthy(0) # False
is_truthy("some string") # True
is_truthy("") # False
The best I’ve come up with is this:
def is_truthy(obj):
return not not obj
Can anybody do better?
The builtins got you covered.