def iter_pairs(iterable):
"""
Iterate over the (key, value) pairs in ``iterable``.
This handles dictionaries sensibly, and falls back to assuming the
iterable yields (key, value) pairs. This behaviour is similar to
what Python's ``dict()`` constructor does.
"""
if isinstance(iterable, Mapping):
iterable = iterable.items()
return iter(iterable)
评论列表
文章目录