@@ -317,6 +317,12 @@ msgid ""
317317":exc:`UnicodeDecodeError` if it contained non-ASCII values. This value-"
318318"specific behavior has caused numerous sad faces over the years."
319319msgstr ""
320+ "Python 3.0 使用 *文本* 和 (二进制) *数据* 等概念来替代 Unicode 字符串和 8 位字符串。 所有文本均使用 "
321+ "Unicode;不过 *已编码* Unicode 是以二进制数据来表示的。 用于存放文本的类型是 :class:`str`,用于存放数据的类型是 "
322+ ":class:`bytes`。 与 2.x 场景的最大区别是在 Python 3.0 中任何混用文本和数据的尝试都将引发 "
323+ ":exc:`TypeError`,而当你在 Python 2.x 中混用 Unicode 和 8 位字符串时,如果 8 位字符串恰好仅包含 7 位 "
324+ "(ASCII) 字节数据那就没有问题,但是如果包含非 ASCII 值则将引发 :exc:`UnicodeDecodeError`。 "
325+ "这种依赖于特定值的行为多年来造成了无数的苦恼。"
320326
321327#: ../../whatsnew/3.0.rst:250
322328msgid ""
@@ -343,6 +349,10 @@ msgid ""
343349":class:`bytes` to :class:`str`. You can also use ``bytes(s, encoding=...)``"
344350" and ``str(b, encoding=...)``, respectively."
345351msgstr ""
352+ "由于 :class:`str` 和 :class:`bytes` 类型无法混用,你必须始终在它们之间执行显式转换。 使用 "
353+ ":meth:`str.encode` 将 :class:`str` 转为 :class:`bytes`,并使用 :meth:`bytes.decode`"
354+ " 将 :class:`bytes` 转为 :class:`str`。 你也可以分别使用 ``bytes(s, encoding=...)`` 和 "
355+ "``str(b, encoding=...)``。"
346356
347357#: ../../whatsnew/3.0.rst:268
348358msgid ""
@@ -397,6 +407,13 @@ msgid ""
397407"have a way to override the encoding. There is no longer any need for using "
398408"the encoding-aware streams in the :mod:`codecs` module."
399409msgstr ""
410+ "作为文本文件打开的文件(仍然是 :func:`open` 的默认模式)总是会使用一个编码格式在(内存中的)字符串和(磁盘中的)字节串之间建立映射。 "
411+ "二进制文件(将 mode 参数设为 ``b`` 来打开)在内存中总是会使用数字串。 这意味着如果一个文件是使用不正确的模式或编码格式打开的,I/O "
412+ "操作很可能会报告失败,而不是静默地产生不正确的数据。 这也意味着即使是 Unix 用户在打开文件时也必须指定正确的模式(文本或二进制)。 "
413+ "存在一个依赖于具体平台的默认编码格式,在类 Unix 平台上可以通过 ``LANG`` "
414+ "环境变量来设置(有时也会使用其他一些平台专属的语言区域相关的环境变量)。 在多数情况下,系统默认使用 "
415+ "UTF-8,但并非全都如此;你绝不应该依赖这个默认值。 任何读写超出纯 ASCII 文本范围的内容的应用程序都应该提供重写编码格式的选项。 "
416+ "现在已不再需要使用 :mod:`codecs` 模块中可感知编码格式的流。"
400417
401418#: ../../whatsnew/3.0.rst:304
402419msgid ""
@@ -424,6 +441,12 @@ msgid ""
424441"of strings, filenames that cannot be decoded properly are omitted rather "
425442"than raising :exc:`UnicodeError`."
426443msgstr ""
444+ "文件名是以(Unicode)字符串的形式传给 API 并返回的。 这可能产生特定平台专属的问题因为在某些平台上文件名强制使用字节串。 (另一方面,在 "
445+ "Windows 上文件名则原生存储为 Unicode。) 为绕过此问题,多数接受文件名的 API(例如 :func:`open` 和 :mod:`os`"
446+ " 模块中的许多函数)都同时接受 :class:`bytes` 对象和字符串,而少数 API 会发出要求 :class:`bytes` 返回值的提示。 "
447+ "因而,当参数为 :class:`bytes` 的实例时 :func:`os.listdir` 会返回由 :class:`bytes` "
448+ "实例组成的列表,:func:`os.getcwdb` 则会将当前工作目录作为 :class:`bytes` 实例返回。 请注意当 "
449+ ":func:`os.listdir` 返回字符串的列表时,无法被正确解码的文件名会被忽略而不是引发 :exc:`UnicodeError`。"
427450
428451#: ../../whatsnew/3.0.rst:325
429452msgid ""
@@ -516,6 +539,8 @@ msgid ""
516539"now assign directly to a variable in an outer (but non-global) scope. "
517540":keyword:`!nonlocal` is a new reserved word."
518541msgstr ""
542+ ":pep:`3104`: :keyword:`nonlocal` 语句。 现在你可以使用 ``nonlocal x`` "
543+ "来允许直接赋值到一个外层(但非全局)作用域。 :keyword:`!nonlocal` 是新的保留字。"
519544
520545#: ../../whatsnew/3.0.rst:378
521546msgid ""
@@ -524,17 +549,21 @@ msgid ""
524549"``rest`` object is always a (possibly empty) list; the right-hand side may "
525550"be any iterable. Example::"
526551msgstr ""
552+ ":pep:`3132`: 扩展可迭代对象解包。 你现在可以编写像 ``a, b, *rest = some_sequence`` 这样的代码。 甚至 "
553+ "``*rest, a = stuff``。 ``rest`` 对象将总是为一个(可能为空的)列表;右侧的对象可以是任意可迭代对象。 例如::"
527554
528555#: ../../whatsnew/3.0.rst:385
529556msgid "This sets *a* to ``0``, *b* to ``4``, and *rest* to ``[1, 2, 3]``."
530- msgstr ""
557+ msgstr "这会将 *a* 设为 ``0``,*b* 设为 ``4``,而将 *rest* 设为 ``[1, 2, 3]``。 "
531558
532559#: ../../whatsnew/3.0.rst:387
533560msgid ""
534561"Dictionary comprehensions: ``{k: v for k, v in stuff}`` means the same thing"
535562" as ``dict(stuff)`` but is more flexible. (This is :pep:`274` vindicated. "
536563":-)"
537564msgstr ""
565+ "新增字典推导式: ``{k: v for k, v in stuff}`` 的含义与 ``dict(stuff)`` 相同但是更为灵活。 "
566+ "(对此特性的解释见 :pep:`274`。 :-)"
538567
539568#: ../../whatsnew/3.0.rst:391
540569msgid ""
@@ -543,24 +572,26 @@ msgid ""
543572"``{x for x in stuff}`` means the same thing as ``set(stuff)`` but is more "
544573"flexible."
545574msgstr ""
575+ "新增集合字面值,例如 ``{1, 2}``。 请注意 ``{}`` 是空字典;要用 ``set()`` 表示空集合。 集合推导式也受到支持;例如 "
576+ "``{x for x in stuff}`` 的含义与 ``set(stuff)`` 相同但是更为灵活。"
546577
547578#: ../../whatsnew/3.0.rst:396
548579msgid ""
549580"New octal literals, e.g. ``0o720`` (already in 2.6). The old octal literals"
550581" (``0720``) are gone."
551- msgstr ""
582+ msgstr "新增八进制字面值,例如 ``0o720`` (已存在于 2.6 中)。 旧的八进制字面值 (``0720``) 已不复存在。 "
552583
553584#: ../../whatsnew/3.0.rst:399
554585msgid ""
555586"New binary literals, e.g. ``0b1010`` (already in 2.6), and there is a new "
556587"corresponding built-in function, :func:`bin`."
557- msgstr ""
588+ msgstr "新增二进制字面值,例如 ``0b1010`` (已存在于 2.6 中),还有对应的新增内置函数 :func:`bin`。 "
558589
559590#: ../../whatsnew/3.0.rst:402
560591msgid ""
561592"Bytes literals are introduced with a leading ``b`` or ``B``, and there is a "
562593"new corresponding built-in function, :func:`bytes`."
563- msgstr ""
594+ msgstr "引入了带有 ``b`` 或 ``B`` 前缀的字节串字面值,还有对应的新增内置函数 :func:`bytes`。 "
564595
565596#: ../../whatsnew/3.0.rst:406
566597msgid "Changed Syntax"
@@ -620,6 +651,9 @@ msgid ""
620651"inside a :func:`list` constructor, and in particular the loop control "
621652"variables are no longer leaked into the surrounding scope."
622653msgstr ""
654+ "列表推导式不再支持 :samp:`[... for {var} in {item1}, {item2}, ...]` 这样的语法形式。 请改用 "
655+ ":samp:`[... for {var} in ({item1}, {item2}, ...)]`。 还要注意列表推导式具有不同的句法:它们更像是 "
656+ ":func:`list` 构造器内部用于生成器表达式的语法糖,具体来说就是循环控制变量将不会再泄漏到外层作用域中。"
623657
624658#: ../../whatsnew/3.0.rst:444
625659msgid ""
@@ -640,14 +674,16 @@ msgid ""
640674":pep:`3113`: Tuple parameter unpacking removed. You can no longer write "
641675"``def foo(a, (b, c)): ...``. Use ``def foo(a, b_c): b, c = b_c`` instead."
642676msgstr ""
677+ ":pep:`3113`: 元组形参解包已被移除。 你不能再使用 ``def foo(a, (b, c)): ...`` 的写法。 请改用 ``def "
678+ "foo(a, b_c): b, c = b_c``。"
643679
644680#: ../../whatsnew/3.0.rst:456
645681msgid "Removed backticks (use :func:`repr` instead)."
646- msgstr ""
682+ msgstr "移除了反引号 (请改用 :func:`repr`)。 "
647683
648684#: ../../whatsnew/3.0.rst:458
649685msgid "Removed ``<>`` (use ``!=`` instead)."
650- msgstr ""
686+ msgstr "移除了 ``<>`` (请改用 ``!=``)。 "
651687
652688#: ../../whatsnew/3.0.rst:460
653689msgid ""
@@ -656,35 +692,40 @@ msgid ""
656692" note that :func:`exec` no longer takes a stream argument; instead of "
657693"``exec(f)`` you can use ``exec(f.read())``."
658694msgstr ""
695+ "移除的关键字: :func:`exec` 不再是一个关键字;它仍是一个函数。 (幸运的是该函数语法也在 2.x 中被接受。) 还要注意 "
696+ ":func:`exec` 将不再接受流作为参数;你可以将原来的 ``exec(f)`` 改为使用 ``exec(f.read())``。"
659697
660698#: ../../whatsnew/3.0.rst:465
661699msgid "Integer literals no longer support a trailing ``l`` or ``L``."
662- msgstr ""
700+ msgstr "整数字面值不再支持 ``l`` 或 ``L`` 后缀。 "
663701
664702#: ../../whatsnew/3.0.rst:467
665703msgid "String literals no longer support a leading ``u`` or ``U``."
666- msgstr ""
704+ msgstr "字符串字面值不再支持 ``u`` 或 ``U`` 前缀。 "
667705
668706#: ../../whatsnew/3.0.rst:469
669707msgid ""
670708"The :keyword:`from` *module* :keyword:`import` ``*`` syntax is only allowed "
671709"at the module level, no longer inside functions."
672710msgstr ""
711+ ":keyword:`from` *module* :keyword:`import` ``*`` 语法仅允许在模块层级使用,不再允许出现于函数内部。"
673712
674713#: ../../whatsnew/3.0.rst:472
675714msgid ""
676715"The only acceptable syntax for relative imports is :samp:`from .[{module}] "
677716"import {name}`. All :keyword:`import` forms not starting with ``.`` are "
678717"interpreted as absolute imports. (:pep:`328`)"
679718msgstr ""
719+ "唯一可接受的相对导入语法为 :samp:`from .[{module}] import {name}`。 所有不以 ``.`` 开头的 "
720+ ":keyword:`import` 形式都将被解读为绝对导入。 (:pep:`328`)"
680721
681722#: ../../whatsnew/3.0.rst:476
682723msgid "Classic classes are gone."
683- msgstr ""
724+ msgstr "经典类已不复存在。 "
684725
685726#: ../../whatsnew/3.0.rst:480
686727msgid "Changes Already Present In Python 2.6"
687- msgstr ""
728+ msgstr "已存在于 Python 2.6 中的改变 "
688729
689730#: ../../whatsnew/3.0.rst:482
690731msgid ""
@@ -694,19 +735,23 @@ msgid ""
694735"corresponding sections in :ref:`whats-new-in-2.6` should be consulted for "
695736"longer descriptions."
696737msgstr ""
738+ "由于许多用户可能会直接从 Python 2.5 跳到 Python 3.0,因此本节提醒读者注意最初为 Python 3.0 设计但后来移植到 "
739+ "Python 2.6 的新特性。 如需更详细的说明请参阅 :ref:`whats-new-in-2.6` 中的相应章节。"
697740
698741#: ../../whatsnew/3.0.rst:488
699742msgid ""
700743":ref:`pep-0343`. The :keyword:`with` statement is now a standard feature "
701744"and no longer needs to be imported from the :mod:`__future__`. Also check "
702745"out :ref:`new-26-context-managers` and :ref:`new-module-contextlib`."
703746msgstr ""
747+ ":ref:`pep-0343`。 现在 :keyword:`with` 语句已是一个标准特性而不再需要从 :mod:`__future__` 导入。 "
748+ "另请参阅 :ref:`new-26-context-managers` 和 :ref:`new-module-contextlib`。"
704749
705750#: ../../whatsnew/3.0.rst:493
706751msgid ""
707752":ref:`pep-0366`. This enhances the usefulness of the :option:`-m` option "
708753"when the referenced module lives in a package."
709- msgstr ""
754+ msgstr ":ref:`pep-0366`。 这增强了 :option:`-m` 选项在被引用的模块位于包中时的实用性。 "
710755
711756#: ../../whatsnew/3.0.rst:496
712757msgid ":ref:`pep-0370`."
@@ -725,26 +770,33 @@ msgid ""
725770"API for string formatting, and to start deprecating the ``%`` operator in "
726771"Python 3.1."
727772msgstr ""
773+ ":ref:`pep-3101`。 注意:2.6 说明文档提到 :meth:`format` 方法同时适用于 8 位和 Unicode 字符串。 在 "
774+ "3.0 中,只有 :class:`str` 类型(带有 Unicode 支持的文本字符串)才支持此方法;:class:`bytes` 类型并不支持。 "
775+ "最终的计划是使其成为仅针对字符串格式化的 API,并在 Python 3.1 中开始弃用 ``%`` 字符串运算符。"
728776
729777#: ../../whatsnew/3.0.rst:507
730778msgid ""
731779":ref:`pep-3105`. This is now a standard feature and no longer needs to be "
732780"imported from :mod:`__future__`. More details were given above."
733- msgstr ""
781+ msgstr ":ref:`pep-3105`。 现在这已是一个标准特性而不再需要从 :mod:`__future__` 导入。 更多详情见上文。 "
734782
735783#: ../../whatsnew/3.0.rst:510
736784msgid ""
737785":ref:`pep-3110`. The :keyword:`except` *exc* :keyword:`!as` *var* syntax is"
738786" now standard and :keyword:`!except` *exc*, *var* is no longer supported. "
739787"(Of course, the :keyword:`!as` *var* part is still optional.)"
740788msgstr ""
789+ ":ref:`pep-3110`。 现在 :keyword:`except` *exc* :keyword:`!as` *var* 语法已成为标准而 "
790+ ":keyword:`!except` *exc*, *var* 不再受到支持。 (当然,:keyword:`!as` *var* 部分仍为可选项。)"
741791
742792#: ../../whatsnew/3.0.rst:515
743793msgid ""
744794":ref:`pep-3112`. The ``b\" ...\" `` string literal notation (and its variants"
745795" like ``b'...'``, ``b\"\"\" ...\"\"\" ``, and ``br\" ...\" ``) now produces a "
746796"literal of type :class:`bytes`."
747797msgstr ""
798+ ":ref:`pep-3112`。 现在 ``b\" ...\" `` 字节串字面值标记法(及其变化形式如 ``b'...'``, "
799+ "``b\"\"\" ...\"\"\" `` 和 ``br\" ...\" `` 等将产生 :class:`bytes` 类型的字面值。"
748800
749801#: ../../whatsnew/3.0.rst:519
750802msgid ""
@@ -781,7 +833,7 @@ msgstr ""
781833msgid ""
782834":ref:`pep-3127`. As mentioned above, the new octal literal notation is the "
783835"only one supported, and binary literals have been added."
784- msgstr ""
836+ msgstr ":ref:`pep-3127`。 如上文所述,新的八进制字面值标记法是唯一受支持的形式,并增加了二进制字面值。 "
785837
786838#: ../../whatsnew/3.0.rst:543
787839msgid ":ref:`pep-3129`."
@@ -793,6 +845,8 @@ msgid ""
793845"defining Python's\" numeric tower\" . Also note the new :mod:`fractions` "
794846"module which implements :class:`numbers.Rational`."
795847msgstr ""
848+ ":ref:`pep-3141`。 :mod:`numbers` 模块是 ABC 的另一个新用例,它定义了 Python 的“数字层级塔”。 另请注意新的"
849+ " :mod:`fractions` 模块,它实现了 :class:`numbers.Rational`。"
796850
797851#: ../../whatsnew/3.0.rst:551
798852msgid "Library Changes"
@@ -829,7 +883,7 @@ msgstr ""
829883msgid ""
830884"Some modules were renamed because their old name disobeyed :pep:`8`, or for "
831885"various other reasons. Here's the list:"
832- msgstr ""
886+ msgstr "一些模块名称已被修改因为它们的旧名称不符合 :pep:`8`,或是出于各种其他理由。 具体列表如下: "
833887
834888#: ../../whatsnew/3.0.rst:576
835889msgid "Old Name"