On 01/26/2015 10:55 AM, Ethan Furman wrote: > On 01/26/2015 10:40 AM, Paul Moore wrote: > >> There *are* some nastily non-intuitive corner cases (for example, if >> from_env={'a':12} and from_config={'a':13}, I don't have any sort of >> intuition as to what a would be in f(**from_env, **from_config). I'd >> go with 12 because the PEP links multiple **-unpackings with >> collections.ChainMap, but I wouldn't dare rely on that guess). > > In the your example > > from_env = {'a': 12} > from_config = {'a': 13} > > f(**from_env, **from_config) > > I would think 'a' should be 13, as from_config is processed /after/ from_env. > > So which is it?
Going to the PEP: kwargs = dict(kw_arguments) kwargs.update(more_arguments) function(**kwargs) or, if you know to do so: from collections import ChainMap function(**ChainMap(more_arguments, arguments)) I see the arguments to ChainMap are reversed (more_arguments is first), so in Paul's example 'a' would be 13. -- ~Ethan~
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com