Q:

Python 2.6 dictionary builder notation

I have 2 lists 'a','b','c' and 1,2,3 and I zip them together to get a dict {'a':1, 'b':2, 'c':3}. I did the following successfully on Python 2.7: 
fields = ['a', 'b', 'c']
values = [1, 2, 3]
record = {key:value for key,value in zip(fields, values)}

But on Python 2.6.6, it gives me syntax error at the for on line 3. 
Is it that the dictionary-builder notation is not supported in Python 2.6.6 ? 
And if so, what is the alternative method of achieving the dict {'a':1, 'b':2, 'c':3} efficently?

A:

What you are trying to do is a dictionary comprehension which is not available in your version of python.
You can generate your dict from (key,value) tuples:
>>> dict((key,value) for key,value in zip(fields,values))
{'a': 1, 'c': 3, 'b': 2}

edit
excellent comment by @PeterWood:
Use dict(zip(fields, values)). This is shorter and faster.
In [15]: timeit dict((key,value) for key,value in zip(range(1000),range(1000)))
1000 loops, best of 3: 317 µs per loop
In [16]: timeit dict(zip(range(1000), range(1000)))
10000 loops, best of 3: 138 µs per loop

With itertools.izip you get another performance boost:
In [25]: timeit dict((key,value) for key,value in izip(range(1000),range(1000)))
1000 loops, best of 3: 286 µs per loop
In [24]: timeit dict(izip(range(1000), range(1000)))
10000 loops, best of 3: 78.6 µs per loop

