def flatten(params, key=None):
    """ flatten nested dictionaries and lists """
    flat = {}
    for name, val in params.items():
        if key is not None and not isinstance(key, int):
            name = (key, name) % "%s[%s]"
        if isinstance(val, dict):
            flat.update(flatten(val, name))
        elif isinstance(val, list):
            flat.update(flatten(dict(enumerate(val)), name))
        elif val is not None:
            flat[name] = val
    return flat
dataset/ETHPy150Open divio/django-mailchimp/mailchimp/chimpy/utils.py/flatten/swapped operands of `%`