Dictionary from list?
Tim Peters
tim.one at home.com
Tue Oct 23 01:21:04 EDT 2001
[Steve Holden]
> Erm, wouldn't it make more sense (since there isn't a dictionary to start
> with) to implement a "toDict()" method of lists rather than a dictionary
> constructor?
There's already a dictionary() constructor in 2.2, and that's not going to
change (it would be too odd if every scalar and container builtin type had a
builtin constructor except for dicts). One question is what it should do;
all it can do in 2.2b1 is basically silly, amounting to yet another way to
spell "shallow-copy the argument".
Sticking a toDict() method on lists isn't appealing regardless because
"iterable object" is the natural decomposition in 2.2 (for example, a tuple
of two-element lists is just as good of an input argument as a list of
two-element tuples, ditto a generator producing a sequence of address-book
objects that supply an iterator over their name and address fields, and so
on -- "a list" just isn't special here).
More information about the Python-list
mailing list