I have met once before, this time in the group also encountered a few times a problem
A program written in python2.7, which uses a dictionary derivation, but the server version is python2.6, unable to run.
Today, we checked the following about Dict comprehensions, which is clearly stated in pep274.
http://legacy.python.org/dev/peps/pep-0274/
Implementation
All implementation details were resolved in the Python 2.7 and 3.0 time-frame.
This was added after 2.7.
2.6 Version of how we use it, in fact, with a For loop to solve the better
#表达式写法In [4]: print {I:CHR (65+i) for I in range (4)}{0: ' A ', 1: ' B ', 2: ' C ', 3: ' D '}
#for循环写法In [5]: D = {}in [6]: For I in range (4): ...: d[i] = chr (65+i) ...: in [7]: Print d{0: ' A ', 1: ' B ', 2: ' C ', 3: ' D '}
This article is derived from"Orangleliu Notebook" Blog, be sure to keep this source http://blog.csdn.net/orangleliu/article/details/39895669
[Python] Dictionary derivation PEP 274--Dict comprehensions