cpython/Lib/test/test_zipfile/_itertools.py

13 lines
301 B
Python

# from more_itertools v8.13.0
def always_iterable(obj, base_type=(str, bytes)):
if obj is None:
return iter(())
if (base_type is not None) and isinstance(obj, base_type):
return iter((obj,))
try:
return iter(obj)
except TypeError:
return iter((obj,))