Note that namedtuples with identical name and fields are always considered
to have the same shallow structure (even with check_types=True).
For instance, this code will print True:
def nt(a, b):
return collections.namedtuple('foo', 'a b')(a, b)
print(assert_same_structure(nt(0, 1), nt(2, 3)))
Args
nest1
an arbitrarily nested structure.
nest2
an arbitrarily nested structure.
check_types
if True (default) types of sequences are checked as well,
including the keys of dictionaries. If set to False, for example a
list and a tuple of objects will look the same if they have the same
size. Note that namedtuples with identical name and fields are always
considered to have the same shallow structure. Two types will also be
considered the same if they are both list subtypes (which allows "list"
and "_ListWrapper" from trackable dependency tracking to compare
equal).