S
Steven D'Aprano
The reason I preferred len(), btw., was only that len() make it clear
that the argument is a sequence.
Maybe I was just too annoyed by lots of Python code I read that looked
like this:
def foo(x, y, z):
if x:
...
else:
...
with poorly named variables where I didn't know what the heck the
variables are (bool, list, instance, ...).
Have you considered that perhaps you don't need to know what the type of
the variables are? Duck typing and all that.
Besides, if the problem is "poorly named variables", the solution *isn't*
to call arbitrary functions on them.
len(x)
x could be a set, a dict, an unsorted list, a sorted list, a tuple, a
deque, a heap, a binary tree, a graph, a stack, a queue, ...