Re: Combining lists to dictionary

2014-11-11 Thread Dave Angel
Ben Finney Wrote in message: > Denis McMahon writes: > >> Hi >> >> Given x,y are a lists of keys and value that I wish to combine to a >> dictionary, such that x[n] is the key for value y[n], which is preferred: >> >> z = {a:b for (a,b) in zip(x,y)} > > This one, with the caveat to use PEP-8 c

Re: Combining lists to dictionary

2014-11-11 Thread Ben Finney
Denis McMahon writes: > Hi > > Given x,y are a lists of keys and value that I wish to combine to a > dictionary, such that x[n] is the key for value y[n], which is preferred: > > z = {a:b for (a,b) in zip(x,y)} This one, with the caveat to use PEP-8 compatible formatting:: z = {a: b for (a

Re: Combining lists to dictionary

2014-11-11 Thread Roy Smith
In article , Denis McMahon wrote: > Hi > > Given x,y are a lists of keys and value that I wish to combine to a > dictionary, such that x[n] is the key for value y[n], which is preferred: > > z = {a:b for (a,b) in zip(x,y)} > z = {x[n]:y[n] for n in range(min(len(x),len(y)))} > > The zip feel

Re: Combining lists to dictionary

2014-11-11 Thread Rob Gaddi
On Tue, 11 Nov 2014 20:43:01 + (UTC) Denis McMahon wrote: > Hi > > Given x,y are a lists of keys and value that I wish to combine to a > dictionary, such that x[n] is the key for value y[n], which is preferred: > > z = {a:b for (a,b) in zip(x,y)} > z = {x[n]:y[n] for n in range(min(len(x),

Re: Combining lists to dictionary

2014-11-11 Thread Gary Herron
On 11/11/2014 12:43 PM, Denis McMahon wrote: Hi Given x,y are a lists of keys and value that I wish to combine to a dictionary, such that x[n] is the key for value y[n], which is preferred: z = {a:b for (a,b) in zip(x,y)} z = {x[n]:y[n] for n in range(min(len(x),len(y)))} The zip feels more el

Combining lists to dictionary

2014-11-11 Thread Denis McMahon
Hi Given x,y are a lists of keys and value that I wish to combine to a dictionary, such that x[n] is the key for value y[n], which is preferred: z = {a:b for (a,b) in zip(x,y)} z = {x[n]:y[n] for n in range(min(len(x),len(y)))} The zip feels more elegant, but it seems clunky to use the zip meth