[Python-Dev] [UPDATE] PEP 274, Dict Comprehensions

Tim Peters tim.one@home.com
Mon, 29 Oct 2001 14:14:39 -0500


[Barry]
> Rationale
>
>     There are times when you have some data arranged as a sequences of
>     length-2 sequences, and you want to turn that into a dictionary.
>     In Python 2.2, the dictionary() constructor will take an optional
>     keyword argument that indicates specifically to interpret a
>     sequences of length-2 sequences as key/value pairs, and turn them
>     into a dictionary.

This is implemented now, but in a different way.  Suggested rewording:

    In Python 2.2, the dictionary() constructor accepts an argument
    that is a sequence of length-2 sequences, used as (key, value)
    pairs to initialize a new dictionary object.


BTW, and not meaning to hijack your PEP <wink>, should dict.update() accept
such an argument too?  I didn't add it because

    d.update(dictionary(such_an_argument))

seemed "almost good enough".

BTW2, are we going to rename "dictionary" to "dict" before 2.2b2?  Before
2.2, "dict" was universally used on c.l.py to mean dictionary, and I'm at
least +0 on adopting that for official 2.2 use.