def ensure_iter(s, cls, copy=False, iterate=True):
    'Given not a list, would place it into a list. If None - empty list is returned\n\n    Parameters\n    ----------\n    s: list or anything\n    cls: class\n      Which iterable class to ensure\n    copy: bool, optional\n      If correct iterable is passed, it would generate its shallow copy\n    iterate: bool, optional\n      If it is not a list, but something iterable (but not a str)\n      iterate over it.\n    '
    if isinstance(s, cls):
        return (s if (not copy) else shallow_copy(s))
    elif isinstance(s, str):
        return cls((s,))
    elif (iterate and hasattr(s, '__iter__')):
        return cls(s)
    elif (s is None):
        return cls()
    else:
        return cls((s,))
Given not a list, would place it into a list. If None - empty list is returned

Parameters
----------
s: list or anything
cls: class
  Which iterable class to ensure
copy: bool, optional
  If correct iterable is passed, it would generate its shallow copy
iterate: bool, optional
  If it is not a list, but something iterable (but not a str)
  iterate over it.
def ensure_iter(s, cls, copy=False, iterate=True):
    'Given not a list, would place it into a list. If None - empty list is returned\n\n    Parameters\n    ----------\n    s: list or anything\n    cls: class\n      Which iterable class to ensure\n    copy: bool, optional\n      If correct iterable is passed, it would generate its shallow copy\n    iterate: bool, optional\n      If it is not a list, but something iterable (but not a str)\n      iterate over it.\n    '
    if isinstance(s, cls):
        return (s if (not copy) else shallow_copy(s))
    elif isinstance(s, str):
        return cls((s,))
    elif (iterate and hasattr(s, '__iter__')):
        return cls(s)
    elif (s is None):
        return cls()
    else:
        return cls((s,))