def import_string(import_name):
    """Imports an object based on a string. This is useful if you want to
    use import paths as endpoints or something similar.

    :param import_name: the dotted name for the object to import.
    :return: imported object
    """
    import_name = str(import_name)
    if ':' in import_name:
        module, obj = import_name.split(':', 1)
        return getattr(__import__(module, None, None, [obj]), obj)
    elif '.' in import_name:
        module, obj = import_name.rsplit('.', 1)
        return getattr(__import__(module, None, None, [obj]), obj)
    else:
        return __import__(import_name)
