Faster (smarter?) dictionary building

Michael T. Babcock mbabcock at fibrespeed.net
Mon Nov 3 08:36:55 EST 2003


> Subject:
> Re: Faster (smarter?) dictionary building
> From:
> David Eppstein <eppstein at ics.uci.edu>
> Date:
> Thu, 30 Oct 2003 12:24:23 -0800
> To:
> python-list at python.org
>
>
>In article <mailman.259.1067543149.702.python-list at python.org>,
> "Michael T. Babcock" <mbabcock at fibrespeed.net> wrote:
>
>  
>
>>I have a list of column headings and an array of values:
>>headings, values = ['a', 'b', 'c'], [1, 2, 3]
>>
>>I want to construct a dictionary such that d['a'] = 1 and so on.
>>    
>>
>
>d = dict(zip(headings,values))
>
>  
>

Beautiful; thank-you very much.  I was sure my code looked uglier than 
necessary.

-- 
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock







More information about the Python-list mailing list