@@ -3035,18 +3035,25 @@ msgid ""
30353035"negative values), :exc:`IndexError` should be raised. For mapping types, if "
30363036"*key* is missing (not in the container), :exc:`KeyError` should be raised."
30373037msgstr ""
3038+ "调用此方法以实现 ``self[key]`` "
3039+ "的求值。对于序列类型,接受的键应为整数和切片对象。请注意负数索引(如果类想要模拟序列类型)的特殊解读是取决于 :meth:`__getitem__` "
3040+ "方法。如果 *key* 的类型不正确则会引发 :exc:`TypeError` "
3041+ "异常;如果为序列索引集范围以外的值(在进行任何负数索引的特殊解读之后)则应引发 :exc:`IndexError` 异常。对于映射类型,如果 *key*"
3042+ " 找不到(不在容器中)则应引发 :exc:`KeyError` 异常。"
30383043
30393044#: ../../reference/datamodel.rst:2178
30403045msgid ""
30413046":keyword:`for` loops expect that an :exc:`IndexError` will be raised for "
30423047"illegal indexes to allow proper detection of the end of the sequence."
3043- msgstr ""
3048+ msgstr ":keyword:`for` 循环在有不合法索引时会期待捕获 :exc:`IndexError` 以便正确地检测到序列的结束。 "
30443049
30453050#: ../../reference/datamodel.rst:2184
30463051msgid ""
30473052"Called by :class:`dict`\\ .\\ :meth:`__getitem__` to implement ``self[key]``"
30483053" for dict subclasses when key is not in the dictionary."
30493054msgstr ""
3055+ "此方法由 :class:`dict`\\ .\\ :meth:`__getitem__` 在找不到字典中的键时调用以实现 dict 子类的 "
3056+ "``self[key]``。"
30503057
30513058#: ../../reference/datamodel.rst:2190
30523059msgid ""
@@ -3056,6 +3063,9 @@ msgid ""
30563063" or for sequences if elements can be replaced. The same exceptions should "
30573064"be raised for improper *key* values as for the :meth:`__getitem__` method."
30583065msgstr ""
3066+ "调用此方法以实现向 ``self[key]`` 赋值。注意事项与 :meth:`__getitem__` "
3067+ "相同。为对象实现此方法应该仅限于需要映射允许基于键修改值或添加键,或是序列允许元素被替换时。不正确的 *key* 值所引发的异常应与 "
3068+ ":meth:`__getitem__` 方法的情况相同。"
30593069
30603070#: ../../reference/datamodel.rst:2199
30613071msgid ""
@@ -3065,6 +3075,9 @@ msgid ""
30653075" from the sequence. The same exceptions should be raised for improper *key*"
30663076" values as for the :meth:`__getitem__` method."
30673077msgstr ""
3078+ "调用此方法以实现 ``self[key]`` 的删除。注意事项与 :meth:`__getitem__` "
3079+ "相同。为对象实现此方法应该权限于需要映射允许移除键,或是序列允许移除元素时。不正确的 *key* 值所引发的异常应与 "
3080+ ":meth:`__getitem__` 方法的情况相同。"
30683081
30693082#: ../../reference/datamodel.rst:2208
30703083msgid ""
@@ -3073,13 +3086,14 @@ msgid ""
30733086"objects in the container. For mappings, it should iterate over the keys of "
30743087"the container."
30753088msgstr ""
3089+ "此方法在需要为容器创建迭代器时被调用。此方法应该返回一个新的迭代器对象,它能够逐个迭代容器中的所有对象。对于映射,它应该逐个迭代容器中的键。"
30763090
30773091#: ../../reference/datamodel.rst:2212
30783092msgid ""
30793093"Iterator objects also need to implement this method; they are required to "
30803094"return themselves. For more information on iterator objects, see "
30813095":ref:`typeiter`."
3082- msgstr ""
3096+ msgstr "迭代器对象也需要实现此方法;它们需要返回对象自身。有关迭代器对象的详情请参看 :ref:`typeiter` 一节。 "
30833097
30843098#: ../../reference/datamodel.rst:2218
30853099msgid ""
0 commit comments