On 21 January 2011 06:13, Bruce Leban <bruce@leapyear.org> wrote:
Back to the original problem though: if the issue is that creating an ordered dict is clumsy and perhaps interfering with adoption and usage then perhaps the notation for ordered dict could be improved. Just as we can now use {...} for both dicts and sets, perhaps we could add
[ 'b' : 1, 'a' : 2 ]
as a more convenient way of writing
OrderedDict([('b', 1), ('a', 2)])
This is parallel to the way that [1,2] is an ordered container while {1,2} is unordered.
['b':1] would then be ambiguous (appears to be a slice of a list). More obvious in the case of [1:2] ... Personally, I'm of the opinion that if an actual dictionary or subclass is passed via **kw, the same type of dictionary should be used for the keyword arguments i.e.: test(**dict(a=1, b=2)) => unordered dict passed. test(**odict(a=1, b=2)) => ordered dict passed. The only difficulty then is passing parameters into the ordered dict constructor in the desired order - I can't think of a reasonable way of doing that. Good old chicken and egg problem. Tim Delaney