Unpacking multiple dictionaries in a function?

Paul Rubin no.email at nospam.invalid
Sat Feb 12 21:33:28 CET 2011


Martin De Kauwe <mdekauwe at gmail.com> writes:
>     def wrapper(*old_dicts):
>         dict={}
>         for d in old_dicts:
>             dict.update(d)
>         return f(**dict)

Untested:

    from itertools import chain
    def wrapper(*old_dicts):
       return f(**dict(chain(d.iteritems() for d in old_dicts)))



More information about the Python-list mailing list