Is there a Pythonic way to check if a list (a nested list with elements & lists) is essentially empty? What I mean by
I don't think there is an obvious way to do it in Python. My best guess would be to use a recursive function like this one :
def empty(li):
if li == []:
return True
else:
return all((isinstance(sli, list) and empty(sli)) for sli in li)
Note that all only comes with Python >= 2.5, and that it will not handle infinitely recursive lists (for example, a = []; a.append(a)).