True
or False
using the equivalence operator// Recommended
if my_bool:
return ''
if
statements.// Recommended
my_list = []
if not my_list:
print('List is empty!')
if x:
when you mean if x is not None
not None
and truthy are not equivalent. For instance, empty lists are evaluated as falsy, yet they are not None.
// Recommended
if arg is not None:
// Do something
// Not recommended
if arg:
// Do something
// recommended
my_list = [1, 2, 3]
// Not recommended
my_list = [ 1, 2, 3, ]
// recommended
tuple = (1,)
// Not recommended
tuple = (1, )