April 10, 2014
10:04 p.m.
Wouldn't another, much less invasive, much more explicit approach be to not squash subclasses of dict when passed into **args? IOW, the way to preserve order would be:
def foo(**kws): ... print(kws) ... from collections import OrderedDict as od foo(**od(a=1, b=2, c=3)) OrderedDict([('a', 1), ('c', 3), ('b', 2)]) # instead of: {'a': 1, 'c': 3, 'b': 2}
? Okay, if you call it with keyword syntax, e.g.
foo(a=3, b=2, c=1) {'c': 1, 'a': 3, 'b': 2}
but oh well. -Barry