Python: Check if all dictionaries in list are empty
- by Brant
I have a list of dictionaries. I need to check if all the dictionaries in that list are empty. I am looking for a simple statement that will do it in one line.
Is there a single line way to do the following (not including the print)?
l = [{},{},{}] # this list is generated elsewhere...
all_empty = True
for i in l:
if i:
all_empty = False
print all_empty
Somewhat new to python... I don't know if there is a shorthand built-in way to check this. Thanks in advance.