考虑这个例子?
p = [1,2,3,4], (1,2,3), set([1,2,3])]
而不是检查每种类型
for x in p:
if isinstance(x, list):
xxxxx
elif isinstance(x, tuple):
xxxxxx
elif isinstance(x, set):
xxxxxxx
是否有以下等效项:
for element in something:
if isinstance(x, iterable):
do something