@@ -446,6 +446,9 @@ msgid ""
446446"and Windows uses a two-character sequence of a carriage return plus a "
447447"newline."
448448msgstr ""
449+ "目前使用的三大操作系统是微软的 Windows、苹果的 Macintosh OS 和各种 Unix "
450+ "衍生系统。跨平台工作的一个小麻烦是,这三个平台都使用不同的字符来标记文本文件中的行结束。Unix 使用换行符(ASCII 字符 10),MacOS "
451+ "使用回车符(ASCII 字符 13),Windows 使用回车符加换行符的双字符序列。"
449452
450453#: ../../whatsnew/2.3.rst:384
451454msgid ""
@@ -471,6 +474,8 @@ msgid ""
471474":option:`!--without-universal-newlines` switch when running Python's "
472475":program:`configure` script."
473476msgstr ""
477+ "在编译 Python 时,可以通过在运行 Python 的 :program:`configure` 脚本时指定 :option:`!--"
478+ "without-universal-newlines` 开关禁用该功能。"
474479
475480#: ../../whatsnew/2.3.rst:403
476481msgid ":pep:`278` - Universal Newline Support"
@@ -491,6 +496,9 @@ msgid ""
491496"sequence, returns an iterator that will return ``(0, thing[0])``, ``(1, "
492497"thing[1])``, ``(2, thing[2])``, and so forth."
493498msgstr ""
499+ "新的内置函数 :func:`enumerate` 将使某些循环更加清晰。 在 ``enumerate(thing)`` 中,如果 *thing* "
500+ "是迭代器或序列,则返回一个迭代器,该迭代器将返回 ``(0, thing[0])``,``(1, thing[1])``,``(2, "
501+ "thing[2])``,以此类推。"
494502
495503#: ../../whatsnew/2.3.rst:419
496504msgid "A common idiom to change every element of a list looks like this::"
@@ -523,6 +531,9 @@ msgid ""
523531"log, or even e-mail them to a particular address; of course, it's also "
524532"possible to write your own handler classes."
525533msgstr ""
534+ "Python 2.3 中新增了一个用于编写日志的标准软件包 :mod:`logging`。 "
535+ "它为生成日志输出提供了一个强大而灵活的机制,这些输出可以通过各种方式进行过滤和处理。用标准格式编写的配置文件可以用来控制程序的日志行为。 Python "
536+ "包含的处理器可以将日志记录写入标准错误、文件或套接字,发送到系统日志,甚至通过电子邮件发送到特定地址;当然,您也可以编写自己的处理器类。"
526537
527538#: ../../whatsnew/2.3.rst:453
528539msgid ""
@@ -608,6 +619,8 @@ msgid ""
608619"documentation for all of the details. Reading :pep:`282` will also be "
609620"helpful."
610621msgstr ""
622+ ":mod:`logging` 软件包具有所有这些功能,即使是最复杂的应用程序也能灵活运用。 "
623+ "本文仅是对其功能的不完整概述,因此请参阅软件包的参考文档了解所有细节。 阅读 :pep:`282` 也会有所帮助。"
611624
612625#: ../../whatsnew/2.3.rst:541
613626msgid ":pep:`282` - A Logging System"
@@ -636,12 +649,14 @@ msgid ""
636649"for it takes any Python value and converts it to :const:`True` or "
637650":const:`False`. ::"
638651msgstr ""
652+ "这个新类型的类型对象名为 :class:`bool`;它的构造函数接收任何 Python 值,并将其转换为 :const:`True` 或 "
653+ ":const:`False`。::"
639654
640655#: ../../whatsnew/2.3.rst:570
641656msgid ""
642657"Most of the standard library modules and built-in functions have been "
643658"changed to return Booleans. ::"
644- msgstr ""
659+ msgstr "大多数标准库模块和内置函数都改为返回布尔值: "
645660
646661#: ../../whatsnew/2.3.rst:581
647662msgid ""
@@ -652,6 +667,8 @@ msgid ""
652667"the statement is ``return True``, however, the meaning of the return value "
653668"is quite clear."
654669msgstr ""
670+ "添加 Python 布尔运算的主要目的是使代码更清晰。 例如,如果您在阅读一个函数时遇到 ``return 1`` 语句,您可能会想知道 ``1`` "
671+ "代表的是布尔真值、索引还是乘以其他量的系数。 然而,如果语句是 ``return True``,返回值的含义就非常清楚了。"
655672
656673#: ../../whatsnew/2.3.rst:587
657674msgid ""
@@ -665,6 +682,10 @@ msgid ""
665682" a subclass of the :class:`int` class so that arithmetic using a Boolean "
666683"still works. ::"
667684msgstr ""
685+ "Python 的布尔值 *不是* 为了严格的类型检查而添加的。 像 Pascal 这样非常严格的语言也会阻止您使用布尔进行算术运算,并要求 "
686+ ":keyword:`if` 语句中的表达式总是求布尔结果。 正如 :pep:`285` 所明确指出的,Python 没有这么严格,以后也不会有。 "
687+ "这意味着您仍然可以在 :keyword:`!if` 语句中使用任何表达式,甚至是求值为 list、tuple 或一些随机对象的表达式。 布尔类型是 "
688+ ":class:`int` 类的子类,因此使用布尔值进行算术运算仍然有效:"
668689
669690#: ../../whatsnew/2.3.rst:605
670691msgid ""
@@ -673,6 +694,9 @@ msgid ""
673694"difference that :func:`str` and :func:`repr` return the strings ``'True'`` "
674695"and ``'False'`` instead of ``'1'`` and ``'0'``."
675696msgstr ""
697+ "用一句话概括 :const:`True` 和 :const:`False`: 它们是拼写整数值 1 和 0 的另一种方式,唯一不同的是 "
698+ ":func:`str` 和 :func:`repr` 返回的字符串是 ``'True'`` 和 ``'False'``,而不是 ``'1'`` 和 "
699+ "``'0'``。"
676700
677701#: ../../whatsnew/2.3.rst:613
678702msgid ":pep:`285` - Adding a bool type"
@@ -697,6 +721,9 @@ msgid ""
697721"inserting an XML character reference or HTML entity reference into the "
698722"converted string."
699723msgstr ""
724+ "将 Unicode 字符串编码为字节字符串时,可能会遇到无法编码的字符。 到目前为止,Python 允许将错误处理指定为 \" strict\" (引发 "
725+ ":exc:`UnicodeError`)、\" ignore\" (跳过该字符) 或 \" replace\" (在输出字符串中使用问号),其中 "
726+ "\" strict\" 是默认行为。 可能需要指定对此类错误的其他处理方式,例如在转换后的字符串中插入 XML 字符引用或 HTML 实体引用。"
700727
701728#: ../../whatsnew/2.3.rst:630
702729msgid ""
@@ -709,13 +736,18 @@ msgid ""
709736"target encoding. The handler can then either raise an exception or return a"
710737" replacement string."
711738msgstr ""
739+ "Python 现在有一个灵活的框架,可以添加不同的处理策略。可以通过 :func:`codecs.register_error` "
740+ "添加新的错误处理器,然后编解码器可以通过 :func:`codecs.lookup_error` 访问错误处理器。 "
741+ "错误处理器会获取必要的状态信息,如正在转换的字符串、字符串中检测到错误的位置以及目标编码。 然后,处理器可以引发异常或返回替换字符串。"
712742
713743#: ../../whatsnew/2.3.rst:638
714744msgid ""
715745"Two additional error handlers have been implemented using this framework: "
716746"\" backslashreplace\" uses Python backslash quoting to represent unencodable "
717747"characters and \" xmlcharrefreplace\" emits XML character references."
718748msgstr ""
749+ "使用该框架还实现了两个额外的错误处理器: \" backslashreplace\" 使用 Python 反斜杠引号来表示无法编码的字符,而 "
750+ "\" xmlcharrefreplace\" 则转换为 XML 字符引用。"
719751
720752#: ../../whatsnew/2.3.rst:645
721753msgid ":pep:`293` - Codec Error Handling Callbacks"
@@ -759,7 +791,7 @@ msgstr ""
759791msgid ""
760792"Here's an example :file:`setup.py` with classifiers, written to be "
761793"compatible with older versions of the Distutils::"
762- msgstr ""
794+ msgstr "下面是一个带有分类器的 :file:`setup.py` 示例,其编写是为了兼容旧版本的 Distutils: "
763795
764796#: ../../whatsnew/2.3.rst:688
765797msgid ""
@@ -804,12 +836,17 @@ msgid ""
804836"an importer object that will handle imports from this path or raises an "
805837":exc:`ImportError` exception if it can't handle this path."
806838msgstr ""
839+ "``sys.path_hooks`` 是一个可调用对象列表,通常是类。 "
840+ "每个可调用对象都接收一个包含路径的字符串,然后返回一个可处理从该路径导入的导入器对象,如果不能处理该路径,则引发 :exc:`ImportError` "
841+ "异常。"
807842
808843#: ../../whatsnew/2.3.rst:721
809844msgid ""
810845"``sys.path_importer_cache`` caches importer objects for each path, so "
811846"``sys.path_hooks`` will only need to be traversed once for each path."
812847msgstr ""
848+ "``sys.path_importer_cache`` 会缓存每条路径的导入器对象,因此 ``sys.path_hooks`` 只需为每条路径遍历一次。"
849+ " "
813850
814851#: ../../whatsnew/2.3.rst:724
815852msgid ""
@@ -818,6 +855,8 @@ msgid ""
818855" can add objects to it. Additional built-in and frozen modules can be "
819856"imported by an object added to this list."
820857msgstr ""
858+ "``sys.meta_path`` 是一个导入器对象列表,在检查 ``sys.path`` 之前将遍历该列表。 "
859+ "该列表最初为空,但用户代码可以向其中添加对象。 其他内置模块和冻结模块可以通过添加到该列表中的对象导入。"
821860
822861#: ../../whatsnew/2.3.rst:729
823862msgid ""
@@ -832,7 +871,7 @@ msgstr ""
832871msgid ""
833872"Pseudo-code for Python's new import logic, therefore, looks something like "
834873"this (simplified a bit; see :pep:`302` for the full details)::"
835- msgstr ""
874+ msgstr "因此,Python 新导入逻辑的伪代码如下 (略有简化;详情请参见 :pep:`302`): "
836875
837876#: ../../whatsnew/2.3.rst:760
838877msgid ":pep:`302` - New Import Hooks"
@@ -868,7 +907,7 @@ msgstr "读取一行并调用 ``line.split(',')``: 再简单不过了吧? 但
868907msgid ""
869908"A big ugly regular expression can parse this, but using the new :mod:`csv` "
870909"package is much simpler::"
871- msgstr ""
910+ msgstr "一个大的丑陋的正则表达式可以解析这些内容,但使用新的 :mod:`csv` 软件包要简单得多: "
872911
873912#: ../../whatsnew/2.3.rst:793
874913msgid ""
@@ -919,6 +958,9 @@ msgid ""
919958"format. A new constant, :const:`pickle.HIGHEST_PROTOCOL`, can be used to "
920959"select the fanciest protocol available."
921960msgstr ""
961+ "解决办法就是发明一种新的 pickle 协议。 :func:`pickle.dumps` 函数很早就支持文本或二进制标志。 在 2.3 "
962+ "中,该标志从布尔值重新定义为整数:0 表示旧的文本模式 pickle 格式,1 表示旧的二进制格式,现在 2 表示新的 2.3 专用格式。 一个新常量 "
963+ ":const:`pickle.HIGHEST_PROTOCOL` 可用来选择最先进的协议。"
922964
923965#: ../../whatsnew/2.3.rst:830
924966msgid ""
@@ -944,6 +986,8 @@ msgid ""
944986"Software Foundation will maintain a list of standardized codes; there's also"
945987" a range of codes for private use. Currently no codes have been specified."
946988msgstr ""
989+ "为了进一步压缩 pickle 类,现在可以使用整数代码而不是长字符串来标识 pickle 类。 Python "
990+ "软件基金会将维护一个标准化代码列表;还有一系列供私人使用的代码。 目前还没有指定任何代码。"
947991
948992#: ../../whatsnew/2.3.rst:849
949993msgid ":pep:`307` - Extensions to the pickle protocol"
@@ -968,21 +1012,26 @@ msgid ""
9681012" if you tried it. Michael Hudson contributed a patch to fix this "
9691013"shortcoming."
9701014msgstr ""
1015+ "从 Python 1.4 开始,切片语法支持可选的第三个“step”或“stride”参数。例如,这些都是合法的 Python 语法: "
1016+ "``L[1:10:2]``,``L[:-1:1]``,``L[::-1]``。 这是应 Numerical Python 开发者的要求添加到 "
1017+ "Python 中的,因为 Numerical Python 广泛使用第三个参数。 然而,Python 内置的 list、tuple "
1018+ "和字符串序列类型从未支持过这一特性,如果您尝试使用,会引发 :exc:`TypeError`。 Michael Hudson "
1019+ "提供了一个补丁来修复这一缺陷。"
9711020
9721021#: ../../whatsnew/2.3.rst:868
9731022msgid ""
9741023"For example, you can now easily extract the elements of a list that have "
9751024"even indexes::"
976- msgstr ""
1025+ msgstr "例如,您现在可以轻松地提取出具有偶数索引的列表元素: "
9771026
9781027#: ../../whatsnew/2.3.rst:875
9791028msgid ""
9801029"Negative values also work to make a copy of the same list in reverse order::"
981- msgstr ""
1030+ msgstr "也可以用负值以按相反顺序复制相同的列表: "
9821031
9831032#: ../../whatsnew/2.3.rst:880
9841033msgid "This also works for tuples, arrays, and strings::"
985- msgstr ""
1034+ msgstr "这也适用于元组、数组和字符串: "
9861035
9871036#: ../../whatsnew/2.3.rst:888
9881037msgid ""
@@ -991,17 +1040,18 @@ msgid ""
9911040"assignment to extended and regular slices. Assignment to a regular slice "
9921041"can be used to change the length of the sequence::"
9931042msgstr ""
1043+ "如果你有一个可变序列如列表或数组,你可以对扩展切片进行赋值或删除,但对扩展切片的赋值与对常规切片的赋值有一些区别。对常规片段的赋值可以用来改变序列的长度:"
9941044
9951045#: ../../whatsnew/2.3.rst:900
9961046msgid ""
9971047"Extended slices aren't this flexible. When assigning to an extended slice, "
9981048"the list on the right hand side of the statement must contain the same "
9991049"number of items as the slice it is replacing::"
1000- msgstr ""
1050+ msgstr "扩展分片则没有这种灵活性。 在为扩展分片赋值时,语句右侧的列表必须包含与要替换的分片相同数量的项目: "
10011051
10021052#: ../../whatsnew/2.3.rst:917
10031053msgid "Deletion is more straightforward::"
1004- msgstr ""
1054+ msgstr "删除操作更为直观: "
10051055
10061056#: ../../whatsnew/2.3.rst:928
10071057msgid ""
@@ -1011,7 +1061,7 @@ msgstr ""
10111061
10121062#: ../../whatsnew/2.3.rst:934
10131063msgid "Or use slice objects directly in subscripts::"
1014- msgstr ""
1064+ msgstr "或者直接在下标中使用切片对象: "
10151065
10161066#: ../../whatsnew/2.3.rst:939
10171067msgid ""
@@ -1031,6 +1081,8 @@ msgid ""
10311081"This is consistent with Python 2.2, where :class:`int`, :class:`str`, etc., "
10321082"underwent the same change."
10331083msgstr ""
1084+ "从这个例子中还可以看到,内置的 :class:`slice` 对象现在是 slice 类型的类型对象,而不再是函数。 这与 Python 2.2 "
1085+ "是一致的,在 Python 2.2 中,:class:`int`,:class:`str` 等也经历了同样的变化。"
10341086
10351087#: ../../whatsnew/2.3.rst:966
10361088msgid "Other Language Changes"
@@ -1071,12 +1123,14 @@ msgid ""
10711123"that ``isinstance(int(expression), int)`` is false, but that seems unlikely "
10721124"to cause problems in practice."
10731125msgstr ""
1126+ ":func:`int` 类型构造函数现在会返回一个长整数,而不会在字符串或浮点数太大而无法放入整数时引发 :exc:`OverflowError`。 "
1127+ "这可能会导致 ``isinstance(int(expression), int)`` 为假的矛盾结果,但在实践中似乎不太可能造成问题。"
10741128
10751129#: ../../whatsnew/2.3.rst:986
10761130msgid ""
10771131"Built-in types now support the extended slicing syntax, as described in "
10781132"section :ref:`section-slices` of this document."
1079- msgstr ""
1133+ msgstr "内置类型现在支持扩展的切分语法,详见本文档 :ref:`section-slices` 一节。 "
10801134
10811135#: ../../whatsnew/2.3.rst:989
10821136msgid ""
@@ -1093,13 +1147,17 @@ msgid ""
10931147"consistent with slice indexing, so when *pos* is -1 the value will be "
10941148"inserted before the last element, and so forth."
10951149msgstr ""
1150+ "以前 ``list.insert(pos, value)`` 在 *pos* 为负值时会将 *value* 插入到列表的前面。 "
1151+ "现在,该行为已被修改为与切片索引一致,因此当 *pos* 为 -1 时,值将被插入最后一个元素之前,以此类推。"
10961152
10971153#: ../../whatsnew/2.3.rst:999
10981154msgid ""
10991155"``list.index(value)``, which searches for *value* within the list and "
11001156"returns its index, now takes optional *start* and *stop* arguments to limit"
11011157" the search to only part of the list."
11021158msgstr ""
1159+ "``list.index(value)`` 会在列表中搜索 *value*,并返回其索引,现在可以使用可选的 *start* 和 *stop* "
1160+ "参数,将搜索范围限制在列表的一部分。"
11031161
11041162#: ../../whatsnew/2.3.rst:1003
11051163msgid ""
@@ -1108,13 +1166,18 @@ msgid ""
11081166"dictionary. If the requested key isn't present in the dictionary, *default*"
11091167" is returned if it's specified and :exc:`KeyError` raised if it isn't. ::"
11101168msgstr ""
1169+ "字典有一个新方法 ``pop(key[, *default*])``,可返回 *key* "
1170+ "对应的值,并从字典中删除该键/值对。如果请求的键不在字典中,如果指定了 *default*,则返回 *default*,如果没有指定则会引发 "
1171+ ":exc:`KeyError`。 ::"
11111172
11121173#: ../../whatsnew/2.3.rst:1025
11131174msgid ""
11141175"There's also a new class method, ``dict.fromkeys(iterable, value)``, that "
11151176"creates a dictionary with keys taken from the supplied iterator *iterable* "
11161177"and all values set to *value*, defaulting to ``None``."
11171178msgstr ""
1179+ "还有一个新的类方法 ``dict.fromkeys(iterable, value)``,用于创建一个字典,其键取自所提供的迭代器 "
1180+ "*iterable*,所有值设置为 *value*,默认为 ``None``。"
11181181
11191182#: ../../whatsnew/2.3.rst:1029
11201183msgid "(Patches contributed by Raymond Hettinger.)"
@@ -1158,13 +1221,18 @@ msgid ""
11581221":option:`-Walways::PendingDeprecationWarning:: <-W>` on the command line or "
11591222"use :func:`warnings.filterwarnings`."
11601223msgstr ""
1224+ "添加了一个新的警告 :exc:`PendingDeprecationWarning`,用于指示正在被废弃的功能。 默认情况下 *不会* 打印该警告。 "
1225+ "要检查是否使用了将来会被废弃的功能,可在命令行中提供 :option:`-Walways::PendingDeprecationWarning:: "
1226+ "<-W>` 或使用 :func:`warnings.filterwarnings`。"
11611227
11621228#: ../../whatsnew/2.3.rst:1065
11631229msgid ""
11641230"The process of deprecating string-based exceptions, as in ``raise \" Error "
11651231"occurred\" ``, has begun. Raising a string will now trigger "
11661232":exc:`PendingDeprecationWarning`."
11671233msgstr ""
1234+ "与 ``raise \" Error occurred\" `` 一样,基于字符串的异常的废弃过程已经开始。 现在,引发字符串异常将触发 "
1235+ ":exc:`PendingDeprecationWarning`。"
11681236
11691237#: ../../whatsnew/2.3.rst:1069
11701238msgid ""
@@ -1237,6 +1305,9 @@ msgid ""
12371305"lines of those relating to assigning to an instance's "
12381306":attr:`~instance.__class__` attribute."
12391307msgstr ""
1308+ "旧式和新式类之间的不兼容问题之一已被消除:您现在可以为新式类的 :attr:`~definition.__name__` 和 "
1309+ ":attr:`~class.__bases__` 属性赋值。 对 :attr:`~class.__bases__` 的赋值有一些限制,与对实例的 "
1310+ ":attr:`~instance.__class__` 属性的赋值类似。"
12401311
12411312#: ../../whatsnew/2.3.rst:1125
12421313msgid "String Changes"
@@ -1250,6 +1321,9 @@ msgid ""
12501321"and ``X in Y`` will return :const:`True` if *X* is a substring of *Y*. If "
12511322"*X* is the empty string, the result is always :const:`True`. ::"
12521323msgstr ""
1324+ ":keyword:`in` 运算符现在对字符串的作用不同了。 以前,当计算 ``X in Y`` 时,*X* 和 *Y* 都是字符串,*X* "
1325+ "只能是单字符。 现在情况有所改变;*X* 可以是任意长度的字符串,如果 *X* 是 *Y* 的子串,``X in Y`` 将返回 "
1326+ ":const:`True`。 如果 *X* 是空字符串,结果总是 :const:`True`。 ::"
12531327
12541328#: ../../whatsnew/2.3.rst:1140
12551329msgid ""
0 commit comments