def merge_dicts(ds):
    """Merge a sequence of dictionaries."""
    result = {}
    for d in ds:
        for k, v in d.items():
            if k not in result:
                if hasattr(v, 'copy'):
                    result[k] = v.copy()
                else:
                    result[k] = v
            elif hasattr(result[k], 'update'):
                result[k].update(v)
            elif hasattr(result[k], 'extend'):
                result[k].extend(v)
            elif result[k] is None:
                result[k] = v
            elif result[k] == '' and v != '':
                result[k] = v
    return result
