Check if object is list of list in python?

Use isinstance() to check for a specific type:

>>> isinstance([], list)
True

Use all() to test if all elements are of a certain type:

all(isinstance(elem, list) for elem in list_of_lists)

all() short-circuits; if any of the tests returns False, the loop is terminated and False is returned. Only if all but one element returns True does all() need to examine every element of the iterable.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)