I know how to check if a list is empty (Best way to check if a list is empty) and how to check if a numpy array is empty (How can I check whether the numpy array is empty or not?)
I have an element that can be at times a list, and other times an array. I need to check whether this element is empty, without knowing beforehand which one it is. I can think of doing
if isinstance(a, list):
    if a:
        # do something
elif a.any():
    # do something
But I wonder if there might be a more pythonic way of doing this?
 
     
    