dictionary() -> dict()
This commit is contained in:
parent
e678d918f3
commit
a74714dc36
14
pep-0274.txt
14
pep-0274.txt
|
@ -35,9 +35,9 @@ Rationale
|
|||
|
||||
There are times when you have some data arranged as a sequences of
|
||||
length-2 sequences, and you want to turn that into a dictionary.
|
||||
In Python 2.2, the dictionary() constructor accepts an argument
|
||||
that is a sequence of length-2 sequences, used as (key, value)
|
||||
pairs to initialize a new dictionary object.
|
||||
In Python 2.2, the dict() constructor accepts an argument that is
|
||||
a sequence of length-2 sequences, used as (key, value) pairs to
|
||||
initialize a new dictionary object.
|
||||
|
||||
However, the act of turning some data into a sequence of length-2
|
||||
sequences can be inconvenient or inefficient from a memory or
|
||||
|
@ -55,11 +55,11 @@ Rationale
|
|||
|
||||
Semantics
|
||||
|
||||
The semantics of dictionary comprehensions can actually be
|
||||
demonstrated in stock Python 2.2, by passing a list comprehension
|
||||
to the builtin dictionary constructor:
|
||||
The semantics of dict comprehensions can actually be demonstrated
|
||||
in stock Python 2.2, by passing a list comprehension to the
|
||||
builtin dictionary constructor:
|
||||
|
||||
>>> dictionary([(i, chr(65+i)) for i in range(4)])
|
||||
>>> dict([(i, chr(65+i)) for i in range(4)])
|
||||
|
||||
is semantically equivalent to
|
||||
|
||||
|
|
Loading…
Reference in New Issue