Dictionary from list?

Magnus Lie Hetland mlh at idi.ntnu.no
Sun Oct 21 14:34:20 EDT 2001


"Martin von Loewis" <loewis at informatik.hu-berlin.de> wrote in message
news:j4d73hjhma.fsf at informatik.hu-berlin.de...
> Jim Correia <jim.correia at pobox.com> writes:
[snip]

> Note that the list->dictionary conversion is not as obvious as you
> think. Given
>
> [(1,2),(3,4)]
>
> would you like to get
>
> a) {1:2, 3:4}
>
> or
>
> b) {(1,2) : (3,4)}
>
> Your answer is probably b), but many Python people would rather expect
> a) (since it would be the reverse of the .items() operation).

Why would one want b?! (I must have missed some posts here...)

- Magnus, who thinks a is the obvious choice.

> Regards,
> Martin

--
Magnus Lie Hetland
http://hetland.org






More information about the Python-list mailing list