def split_factory(split_by=',', cast_to=list, remove_empty=True, strip = True):
    """
    Creates a uniform function split by a selected expression.

    :param str split_by: Splitting expression
    :param type cast_to: Result type
    :param bool remove_empty: Determines if empty strings should be added to the container
    :param bool strip: Determines if the input is going to be stripped
    of special characters and whitespaces
    :return function: Splitting function
    """

    try:
        assert isinstance(cast_to, type)
    except AssertionError:
        raise RuntimeError('cast_to has to be a type. For example, use set instead of set().')

    def wrapper(text):
        """
        Resulting function of split_factory. Splits text by a predefined expression.

        :param str text:
        :return:
        """

        container = list()

        if strip:
            processor = lambda t : t.strip()
        else:
            processor = lambda t : t

        for part in text.split(split_by):
            if remove_empty:
                if processor(part) != '':
                    container.append(processor(part))
            else:
                container.append(processor(part))

        return cast_to(container)

    return wrapper