def create_connection(Connection, num, host_settings, defaults):
    # host_settings can be an iterable or a dictionary depending on the style
    # of connection (some connections share options and simply just need to
    # pass a single host, or a list of hosts)
    if isinstance(host_settings, collections.Mapping):
        return Connection(num, **apply_defaults(host_settings, defaults or {}))
    elif isinstance(host_settings, collections.Iterable):
        return Connection(num, *host_settings, **defaults or {})
    return Connection(num, host_settings, **defaults or {})
dataset/ETHPy150Open disqus/nydus/nydus/db/base.py/create_connection/original