On 11/17/2016 9:57 AM, Thorsten Kampe wrote:
The code in question is part of an attempt to get the dimensions of
multi-dimensional lists, the `isinstance` is there in order to
exclude strings.
You can do the exclusion directly.
"""
def dim(seq):
dimension = []
while isinstance(seq, (list, tuple)):
while not isinstance(seq, str) # or (str, bytes, ...)
dimension.append(len(seq))
try:
seq = seq[0]
except IndexError: # sequence is empty
break
return dimension
"""
Thorsten
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list