On Thu, Mar 20, 2014 at 10:32 AM, Eric Snow
1. Change kwargs to an OrderedDict for functions decorated a special decorator:
@preserve_kwargs_order def spam(a, b, **kwargs): ... # kwargs will be an OrderedDict
2. Store the ordered keys in a list and bind that to a special local variable, but only for functions that have **kwargs:
def spam(a, b, **kwargs): kwargs = OrderedDict((k, kwargs[k]) for k in __kwargs_order__) ...
My gut feeling is that option 2 is the better choice.
Strongly against any proposal that makes argument passing behave differently based on the target - it means the process of building up the arguments has to check some attribute on the function. Order of kwargs is a problem for any function that passes args through to another function. def wrap_spam(*args, **kwargs): try: return spam(*args, **kwargs) except EggsError: return False Does wrap_spam have to be aware that spam cares about keyword argument order? Should it preserve order "just in case"? Should the __kwargs_order__ list be automatically propagated? And what happens if the args aren't passed through perfectly, but some are added/removed? ChrisA