3 ms·
Well, [k for k in OrderedDict(a=1, b=2)] not that different in valid Python
by coldtea 10y ago
Well,
[k for k in OrderedDict(a=1, b=2)]
not that different in valid Python
- mark-r 10y agoBut as pointed out elsewhere, kwargs aren't guaranteed to be in order, so by the time the OrderedDict is built it's already wrong. It seems the change we're discussing was primarily motivated by a desire to fix that specific problem.
- ak217 10y agoThe point OP is making is that none of these statements will guarantee the order of insertion, since OrderedDict must take the variadic kwargs input as a dict, which is inherently unordered. You have to use a list of tuples.
- coldtea 10y agoYes, agree, just wanted to give the correct Python for the (still) ill attempt at traversing OrderedDict keys in order.