def sliceit(iterable, lower=0, upper=None):
    """Apply a slice on input iterable.

    :param iterable: object which provides the method __getitem__ or __iter__.
    :param int lower: lower bound from where start to get items.
    :param int upper: upper bound from where finish to get items.
    :return: sliced object of the same type of iterable if not dict, or specific
        object. otherwise, simple list of sliced items.
    :rtype: Iterable
    """
    if upper is None:
        upper = len(iterable)
    try:
        result = iterable[lower:upper]
    except TypeError:
        result = []
        if lower < 0:
            lower += len(iterable)
        if upper < 0:
            upper += len(iterable)
        if upper > lower:
            iterator = iter(iterable)
            for index in range(upper):
                try:
                    value = next(iterator)
                except StopIteration:
                    break
                else:
                    if index >= lower:
                        result.append(value)
    iterablecls = iterable.__class__
    if not (isinstance(result, iterablecls) or issubclass(iterablecls, dict)):
        try:
            result = iterablecls(result)
        except TypeError:
            pass
    return result
