[Python-ideas] Ordered storage of keyword arguments (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Fri Oct 29 09:47:54 CEST 2010
- Previous message: [Python-ideas] Ordered storage of keyword arguments
- Next message: [Python-ideas] Ordered storage of keyword arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Chris Rose wrote:
I'm hard pressed to see how an ordered dict and a dict should be expected to differ by such a degree; in every particular they behave the same, except in the case of the OrderedDict you specify your initial parameters in tuples?
Well, you can specify them in tuples for an ordinary dict if you want:
d = dict([('a', 1), ('b', 2)]) d {'a': 1, 'b': 2}
The fact that keywords also work for an ordinary dict is really just a lucky fluke that works in the special case where the keys are identifier-like strings. In any other case you have to use tuples anyway. Also, you get away with it because dicts happen to be unordered. Expecting your luck in this area to extend to other data types is pushing things a bit, I think.
-- Greg
- Previous message: [Python-ideas] Ordered storage of keyword arguments
- Next message: [Python-ideas] Ordered storage of keyword arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]