a dictionary from a list
Raymond Hettinger
python at rcn.com
Mon Jun 27 19:46:02 EDT 2005
[Roy Smith]
> I also think the published description is needlessly confusing. Why does
> it use
>
> {'one': 2, 'two': 3}
>
> as the example mapping when
>
> {'one': 1, 'two': 2}
>
> would illustrate exactly the same point but be easier to comprehend. The
> mapping given is the kind of thing I would expect to see in an obfuscated
> programming contest.
>
> Also, what's the point of the last example:
>
> dict([(['one', 'two'][i-2], i) for i in (2, 3)])
>
> It boils down to passing a list of tuples as an argument, which is already
> illustrated by other examples. This is just a complicated and obtuse way
> to construct the list of tuples. What does it add to the understanding of
> how the dict() constructor works?
If you can switch from indignation to constructive criticism, then
consider sending a note to Andrew Kuchling suggesting ways to improve
the examples.
Raymond
More information about the Python-list
mailing list