You can create a tuple
of all your variables. And then use itertools.filterfalse()
with bool
as predicate value to get all the Falsy values from tuple as:
>>> from itertools import filterfalse
>>> my_list = (1, "a", False, 2.34, "", 0)
>>> list(filterfalse(bool, my_list))
[False, '', 0]
Similarly if you need a list of all the Truthy values, you can use filter()
as:
>>> my_list = (1, "a", False, 2.34, "", 0)
>>> list(filter(bool, my_list))
[1, 'a', 2.34]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…