Function
always_iterable
(obj, base_type=(str, bytes))
Source from the content-addressed store, hash-verified
| 31 | |
| 32 | # from more_itertools v8.13.0 |
| 33 | def always_iterable(obj, base_type=(str, bytes)): |
| 34 | if obj is None: |
| 35 | return iter(()) |
| 36 | |
| 37 | if (base_type is not None) and isinstance(obj, base_type): |
| 38 | return iter((obj,)) |
| 39 | |
| 40 | try: |
| 41 | return iter(obj) |
| 42 | except TypeError: |
| 43 | return iter((obj,)) |
| 44 | |
| 45 | |
| 46 | # from more_itertools v9.0.0 |
Used in the wild real call sites across dependent graphs
searching dependent graphs…