Dictionary from list?

Jim Correia jim.correia at pobox.com
Thu Oct 18 23:42:57 EDT 2001


Suppose I have a list with an even number of elements in the form

[key1, value1, key2, value2, key3, value3]

If I were writing Perl I could write

my %hash = @array;

and it would do the coercion for me, and build the hash appropriately.

I'm a python newbie.  I know how to do it "by hand" with a loop, but is 
there a built in conversion operater that will let me do something 
simply like the perl assignment?

Jim



More information about the Python-list mailing list