5.2.5 字典的表示 Dictionary displays

A dictionary display is a possibly empty series of key/datum pairs enclosed in curly braces:

一个字典用一对大括号括住的 键/数据 对的序列(可能为空)表示:

dict_display  ::=  "{" [key_datum_list] "}"
key_datum_list  ::=  key_datum ("," key_datum)* [","]
key_datum  ::=  expression ":" expression
Download entire grammar as text.

A dictionary display yields a new dictionary object.

使用一个字典会生成一个新的字典对象.

The key/datum pairs are evaluated from left to right to define the entries of the dictionary: each key object is used as a key into the dictionary to store the corresponding datum.

键/数据对按在字典中定义的从左到右的顺序求值:每个键对象作为键嵌入到字典中存储相应的数据.

Restrictions on the types of the key values are listed earlier in section 3.2. (To summarize,the key type should be hashable, which excludes all mutable objects.) Clashes between duplicate keys are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails.

关于键值类型的限制已在前述3.2提及(总而言之,键的类型应该是可散列的,这就排除了所有的可变对象)。重复键之间的冲突不会被检测到;对给定的(有重复的)键来说,最后出现的数据(就是文字显示中出现在最右边的)成为(最终的)胜利者。