@@ -692,6 +692,10 @@ msgid ""
692692" copy of ``y``, you'll instead end up with ``None``, which will likely cause"
693693" your program to generate an easily diagnosed error."
694694msgstr ""
695+ "某些操作 (例如 ``y.append(10)`` 和 ``y.sort()``) 是改变原对象,而看上去相似的另一些操作 (例如 ``y = y + "
696+ "[10]`` 和 ``sorted(y)``) 则是创建新对象。 通常在 Python 中 (以及在标准库的所有代码中) 会改变原对象的方法将返回 "
697+ "``None`` 以帮助避免混淆这两种不同类型的操作。 因此如果你错误地使用了 ``y.sort()`` 并期望它将返回一个经过排序的 ``y`` "
698+ "的副本,你得到的结果将会是 ``None``,这将导致你的程序产生一个容易诊断的错误。"
695699
696700#: ../../faq/programming.rst:490
697701msgid ""
@@ -702,6 +706,9 @@ msgid ""
702706"mutates ``a_list``, whereas ``some_tuple += (1, 2, 3)`` and ``some_int += "
703707"1`` create new objects)."
704708msgstr ""
709+ "但是,还存在一类操作,不同的类型执行相同的操作会有不同的行为:那就是增强赋值运算符。 例如,``+=`` 会原地改变列表,但不会改变元组或整数 "
710+ "(``a_list += [1, 2, 3]`` 与 ``a_list.extend([1, 2, 3])`` 一样都会改变 ``a_list``,而 "
711+ "``some_tuple += (1, 2, 3)`` 和 ``some_int += 1`` 则会创建新的对象)。"
705712
706713#: ../../faq/programming.rst:497
707714msgid "In other words:"
@@ -713,6 +720,8 @@ msgid ""
713720"etc.), we can use some specific operations to mutate it and all the "
714721"variables that refer to it will see the change."
715722msgstr ""
723+ "如果我们有一个可变对象 (:class:`list`, :class:`dict`, :class:`set` "
724+ "等等),我们可以使用某些特定的操作来改变它,所有指向它的变量都会显示它的改变。"
716725
717726#: ../../faq/programming.rst:502
718727msgid ""
@@ -721,12 +730,14 @@ msgid ""
721730"but operations that transform that value into a new value always return a "
722731"new object."
723732msgstr ""
733+ "如果我们有一个不可变对象 (:class:`str`, :class:`int`, :class:`tuple` "
734+ "等等),所有指向它的变量都将显示相同样的值,但凡是会改变这个值的操作将总是返回一个新对象。"
724735
725736#: ../../faq/programming.rst:507
726737msgid ""
727738"If you want to know if two variables refer to the same object or not, you "
728739"can use the :keyword:`is` operator, or the built-in function :func:`id`."
729- msgstr ""
740+ msgstr "如果你想知道两个变量是否指向相同的对象,你可以使用 :keyword:`is` 运算符,或内置函数 :func:`id`。 "
730741
731742#: ../../faq/programming.rst:512
732743msgid "How do I write a function with output parameters (call by reference)?"
0 commit comments