Cope 2.5.0
My personal "standard library" of all the generally useful code I've written for various projects over the years
|
def Cope.misc.ensure_iterable | ( | Iterable | iter, |
type | cast = list , |
||
bool | ensure_cast_type = True |
||
) |
Ensures that iter
is an iterable, if it isn't already.
If iter
is not an iterable, it'll make it one of type cast
, and if ensure_cast_type
is True, it will cast iter
to cast
as well. Otherwise it returns iter
unchanged. Strings, in this context, don't count as iterables.