@@ -446,6 +446,9 @@ msgid ""
446
446
"and Windows uses a two-character sequence of a carriage return plus a "
447
447
"newline."
448
448
msgstr ""
449
+ "目前使用的三大操作系统是微软的 Windows、苹果的 Macintosh OS 和各种 Unix "
450
+ "衍生系统。跨平台工作的一个小麻烦是,这三个平台都使用不同的字符来标记文本文件中的行结束。Unix 使用换行符(ASCII 字符 10),MacOS "
451
+ "使用回车符(ASCII 字符 13),Windows 使用回车符加换行符的双字符序列。"
449
452
450
453
#: ../../whatsnew/2.3.rst:384
451
454
msgid ""
@@ -471,6 +474,8 @@ msgid ""
471
474
":option:`!--without-universal-newlines` switch when running Python's "
472
475
":program:`configure` script."
473
476
msgstr ""
477
+ "在编译 Python 时,可以通过在运行 Python 的 :program:`configure` 脚本时指定 :option:`!--"
478
+ "without-universal-newlines` 开关禁用该功能。"
474
479
475
480
#: ../../whatsnew/2.3.rst:403
476
481
msgid ":pep:`278` - Universal Newline Support"
@@ -491,6 +496,9 @@ msgid ""
491
496
"sequence, returns an iterator that will return ``(0, thing[0])``, ``(1, "
492
497
"thing[1])``, ``(2, thing[2])``, and so forth."
493
498
msgstr ""
499
+ "新的内置函数 :func:`enumerate` 将使某些循环更加清晰。 在 ``enumerate(thing)`` 中,如果 *thing* "
500
+ "是迭代器或序列,则返回一个迭代器,该迭代器将返回 ``(0, thing[0])``,``(1, thing[1])``,``(2, "
501
+ "thing[2])``,以此类推。"
494
502
495
503
#: ../../whatsnew/2.3.rst:419
496
504
msgid "A common idiom to change every element of a list looks like this::"
@@ -523,6 +531,9 @@ msgid ""
523
531
"log, or even e-mail them to a particular address; of course, it's also "
524
532
"possible to write your own handler classes."
525
533
msgstr ""
534
+ "Python 2.3 中新增了一个用于编写日志的标准软件包 :mod:`logging`。 "
535
+ "它为生成日志输出提供了一个强大而灵活的机制,这些输出可以通过各种方式进行过滤和处理。用标准格式编写的配置文件可以用来控制程序的日志行为。 Python "
536
+ "包含的处理器可以将日志记录写入标准错误、文件或套接字,发送到系统日志,甚至通过电子邮件发送到特定地址;当然,您也可以编写自己的处理器类。"
526
537
527
538
#: ../../whatsnew/2.3.rst:453
528
539
msgid ""
@@ -608,6 +619,8 @@ msgid ""
608
619
"documentation for all of the details. Reading :pep:`282` will also be "
609
620
"helpful."
610
621
msgstr ""
622
+ ":mod:`logging` 软件包具有所有这些功能,即使是最复杂的应用程序也能灵活运用。 "
623
+ "本文仅是对其功能的不完整概述,因此请参阅软件包的参考文档了解所有细节。 阅读 :pep:`282` 也会有所帮助。"
611
624
612
625
#: ../../whatsnew/2.3.rst:541
613
626
msgid ":pep:`282` - A Logging System"
@@ -636,12 +649,14 @@ msgid ""
636
649
"for it takes any Python value and converts it to :const:`True` or "
637
650
":const:`False`. ::"
638
651
msgstr ""
652
+ "这个新类型的类型对象名为 :class:`bool`;它的构造函数接收任何 Python 值,并将其转换为 :const:`True` 或 "
653
+ ":const:`False`。::"
639
654
640
655
#: ../../whatsnew/2.3.rst:570
641
656
msgid ""
642
657
"Most of the standard library modules and built-in functions have been "
643
658
"changed to return Booleans. ::"
644
- msgstr ""
659
+ msgstr "大多数标准库模块和内置函数都改为返回布尔值: "
645
660
646
661
#: ../../whatsnew/2.3.rst:581
647
662
msgid ""
@@ -652,6 +667,8 @@ msgid ""
652
667
"the statement is ``return True``, however, the meaning of the return value "
653
668
"is quite clear."
654
669
msgstr ""
670
+ "添加 Python 布尔运算的主要目的是使代码更清晰。 例如,如果您在阅读一个函数时遇到 ``return 1`` 语句,您可能会想知道 ``1`` "
671
+ "代表的是布尔真值、索引还是乘以其他量的系数。 然而,如果语句是 ``return True``,返回值的含义就非常清楚了。"
655
672
656
673
#: ../../whatsnew/2.3.rst:587
657
674
msgid ""
@@ -665,6 +682,10 @@ msgid ""
665
682
" a subclass of the :class:`int` class so that arithmetic using a Boolean "
666
683
"still works. ::"
667
684
msgstr ""
685
+ "Python 的布尔值 *不是* 为了严格的类型检查而添加的。 像 Pascal 这样非常严格的语言也会阻止您使用布尔进行算术运算,并要求 "
686
+ ":keyword:`if` 语句中的表达式总是求布尔结果。 正如 :pep:`285` 所明确指出的,Python 没有这么严格,以后也不会有。 "
687
+ "这意味着您仍然可以在 :keyword:`!if` 语句中使用任何表达式,甚至是求值为 list、tuple 或一些随机对象的表达式。 布尔类型是 "
688
+ ":class:`int` 类的子类,因此使用布尔值进行算术运算仍然有效:"
668
689
669
690
#: ../../whatsnew/2.3.rst:605
670
691
msgid ""
@@ -673,6 +694,9 @@ msgid ""
673
694
"difference that :func:`str` and :func:`repr` return the strings ``'True'`` "
674
695
"and ``'False'`` instead of ``'1'`` and ``'0'``."
675
696
msgstr ""
697
+ "用一句话概括 :const:`True` 和 :const:`False`: 它们是拼写整数值 1 和 0 的另一种方式,唯一不同的是 "
698
+ ":func:`str` 和 :func:`repr` 返回的字符串是 ``'True'`` 和 ``'False'``,而不是 ``'1'`` 和 "
699
+ "``'0'``。"
676
700
677
701
#: ../../whatsnew/2.3.rst:613
678
702
msgid ":pep:`285` - Adding a bool type"
@@ -697,6 +721,9 @@ msgid ""
697
721
"inserting an XML character reference or HTML entity reference into the "
698
722
"converted string."
699
723
msgstr ""
724
+ "将 Unicode 字符串编码为字节字符串时,可能会遇到无法编码的字符。 到目前为止,Python 允许将错误处理指定为 \" strict\" (引发 "
725
+ ":exc:`UnicodeError`)、\" ignore\" (跳过该字符) 或 \" replace\" (在输出字符串中使用问号),其中 "
726
+ "\" strict\" 是默认行为。 可能需要指定对此类错误的其他处理方式,例如在转换后的字符串中插入 XML 字符引用或 HTML 实体引用。"
700
727
701
728
#: ../../whatsnew/2.3.rst:630
702
729
msgid ""
@@ -709,13 +736,18 @@ msgid ""
709
736
"target encoding. The handler can then either raise an exception or return a"
710
737
" replacement string."
711
738
msgstr ""
739
+ "Python 现在有一个灵活的框架,可以添加不同的处理策略。可以通过 :func:`codecs.register_error` "
740
+ "添加新的错误处理器,然后编解码器可以通过 :func:`codecs.lookup_error` 访问错误处理器。 "
741
+ "错误处理器会获取必要的状态信息,如正在转换的字符串、字符串中检测到错误的位置以及目标编码。 然后,处理器可以引发异常或返回替换字符串。"
712
742
713
743
#: ../../whatsnew/2.3.rst:638
714
744
msgid ""
715
745
"Two additional error handlers have been implemented using this framework: "
716
746
"\" backslashreplace\" uses Python backslash quoting to represent unencodable "
717
747
"characters and \" xmlcharrefreplace\" emits XML character references."
718
748
msgstr ""
749
+ "使用该框架还实现了两个额外的错误处理器: \" backslashreplace\" 使用 Python 反斜杠引号来表示无法编码的字符,而 "
750
+ "\" xmlcharrefreplace\" 则转换为 XML 字符引用。"
719
751
720
752
#: ../../whatsnew/2.3.rst:645
721
753
msgid ":pep:`293` - Codec Error Handling Callbacks"
@@ -759,7 +791,7 @@ msgstr ""
759
791
msgid ""
760
792
"Here's an example :file:`setup.py` with classifiers, written to be "
761
793
"compatible with older versions of the Distutils::"
762
- msgstr ""
794
+ msgstr "下面是一个带有分类器的 :file:`setup.py` 示例,其编写是为了兼容旧版本的 Distutils: "
763
795
764
796
#: ../../whatsnew/2.3.rst:688
765
797
msgid ""
@@ -804,12 +836,17 @@ msgid ""
804
836
"an importer object that will handle imports from this path or raises an "
805
837
":exc:`ImportError` exception if it can't handle this path."
806
838
msgstr ""
839
+ "``sys.path_hooks`` 是一个可调用对象列表,通常是类。 "
840
+ "每个可调用对象都接收一个包含路径的字符串,然后返回一个可处理从该路径导入的导入器对象,如果不能处理该路径,则引发 :exc:`ImportError` "
841
+ "异常。"
807
842
808
843
#: ../../whatsnew/2.3.rst:721
809
844
msgid ""
810
845
"``sys.path_importer_cache`` caches importer objects for each path, so "
811
846
"``sys.path_hooks`` will only need to be traversed once for each path."
812
847
msgstr ""
848
+ "``sys.path_importer_cache`` 会缓存每条路径的导入器对象,因此 ``sys.path_hooks`` 只需为每条路径遍历一次。"
849
+ " "
813
850
814
851
#: ../../whatsnew/2.3.rst:724
815
852
msgid ""
@@ -818,6 +855,8 @@ msgid ""
818
855
" can add objects to it. Additional built-in and frozen modules can be "
819
856
"imported by an object added to this list."
820
857
msgstr ""
858
+ "``sys.meta_path`` 是一个导入器对象列表,在检查 ``sys.path`` 之前将遍历该列表。 "
859
+ "该列表最初为空,但用户代码可以向其中添加对象。 其他内置模块和冻结模块可以通过添加到该列表中的对象导入。"
821
860
822
861
#: ../../whatsnew/2.3.rst:729
823
862
msgid ""
@@ -832,7 +871,7 @@ msgstr ""
832
871
msgid ""
833
872
"Pseudo-code for Python's new import logic, therefore, looks something like "
834
873
"this (simplified a bit; see :pep:`302` for the full details)::"
835
- msgstr ""
874
+ msgstr "因此,Python 新导入逻辑的伪代码如下 (略有简化;详情请参见 :pep:`302`): "
836
875
837
876
#: ../../whatsnew/2.3.rst:760
838
877
msgid ":pep:`302` - New Import Hooks"
@@ -868,7 +907,7 @@ msgstr "读取一行并调用 ``line.split(',')``: 再简单不过了吧? 但
868
907
msgid ""
869
908
"A big ugly regular expression can parse this, but using the new :mod:`csv` "
870
909
"package is much simpler::"
871
- msgstr ""
910
+ msgstr "一个大的丑陋的正则表达式可以解析这些内容,但使用新的 :mod:`csv` 软件包要简单得多: "
872
911
873
912
#: ../../whatsnew/2.3.rst:793
874
913
msgid ""
@@ -919,6 +958,9 @@ msgid ""
919
958
"format. A new constant, :const:`pickle.HIGHEST_PROTOCOL`, can be used to "
920
959
"select the fanciest protocol available."
921
960
msgstr ""
961
+ "解决办法就是发明一种新的 pickle 协议。 :func:`pickle.dumps` 函数很早就支持文本或二进制标志。 在 2.3 "
962
+ "中,该标志从布尔值重新定义为整数:0 表示旧的文本模式 pickle 格式,1 表示旧的二进制格式,现在 2 表示新的 2.3 专用格式。 一个新常量 "
963
+ ":const:`pickle.HIGHEST_PROTOCOL` 可用来选择最先进的协议。"
922
964
923
965
#: ../../whatsnew/2.3.rst:830
924
966
msgid ""
@@ -944,6 +986,8 @@ msgid ""
944
986
"Software Foundation will maintain a list of standardized codes; there's also"
945
987
" a range of codes for private use. Currently no codes have been specified."
946
988
msgstr ""
989
+ "为了进一步压缩 pickle 类,现在可以使用整数代码而不是长字符串来标识 pickle 类。 Python "
990
+ "软件基金会将维护一个标准化代码列表;还有一系列供私人使用的代码。 目前还没有指定任何代码。"
947
991
948
992
#: ../../whatsnew/2.3.rst:849
949
993
msgid ":pep:`307` - Extensions to the pickle protocol"
@@ -968,21 +1012,26 @@ msgid ""
968
1012
" if you tried it. Michael Hudson contributed a patch to fix this "
969
1013
"shortcoming."
970
1014
msgstr ""
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
+ "提供了一个补丁来修复这一缺陷。"
971
1020
972
1021
#: ../../whatsnew/2.3.rst:868
973
1022
msgid ""
974
1023
"For example, you can now easily extract the elements of a list that have "
975
1024
"even indexes::"
976
- msgstr ""
1025
+ msgstr "例如,您现在可以轻松地提取出具有偶数索引的列表元素: "
977
1026
978
1027
#: ../../whatsnew/2.3.rst:875
979
1028
msgid ""
980
1029
"Negative values also work to make a copy of the same list in reverse order::"
981
- msgstr ""
1030
+ msgstr "也可以用负值以按相反顺序复制相同的列表: "
982
1031
983
1032
#: ../../whatsnew/2.3.rst:880
984
1033
msgid "This also works for tuples, arrays, and strings::"
985
- msgstr ""
1034
+ msgstr "这也适用于元组、数组和字符串: "
986
1035
987
1036
#: ../../whatsnew/2.3.rst:888
988
1037
msgid ""
@@ -991,17 +1040,18 @@ msgid ""
991
1040
"assignment to extended and regular slices. Assignment to a regular slice "
992
1041
"can be used to change the length of the sequence::"
993
1042
msgstr ""
1043
+ "如果你有一个可变序列如列表或数组,你可以对扩展切片进行赋值或删除,但对扩展切片的赋值与对常规切片的赋值有一些区别。对常规片段的赋值可以用来改变序列的长度:"
994
1044
995
1045
#: ../../whatsnew/2.3.rst:900
996
1046
msgid ""
997
1047
"Extended slices aren't this flexible. When assigning to an extended slice, "
998
1048
"the list on the right hand side of the statement must contain the same "
999
1049
"number of items as the slice it is replacing::"
1000
- msgstr ""
1050
+ msgstr "扩展分片则没有这种灵活性。 在为扩展分片赋值时,语句右侧的列表必须包含与要替换的分片相同数量的项目: "
1001
1051
1002
1052
#: ../../whatsnew/2.3.rst:917
1003
1053
msgid "Deletion is more straightforward::"
1004
- msgstr ""
1054
+ msgstr "删除操作更为直观: "
1005
1055
1006
1056
#: ../../whatsnew/2.3.rst:928
1007
1057
msgid ""
@@ -1011,7 +1061,7 @@ msgstr ""
1011
1061
1012
1062
#: ../../whatsnew/2.3.rst:934
1013
1063
msgid "Or use slice objects directly in subscripts::"
1014
- msgstr ""
1064
+ msgstr "或者直接在下标中使用切片对象: "
1015
1065
1016
1066
#: ../../whatsnew/2.3.rst:939
1017
1067
msgid ""
@@ -1031,6 +1081,8 @@ msgid ""
1031
1081
"This is consistent with Python 2.2, where :class:`int`, :class:`str`, etc., "
1032
1082
"underwent the same change."
1033
1083
msgstr ""
1084
+ "从这个例子中还可以看到,内置的 :class:`slice` 对象现在是 slice 类型的类型对象,而不再是函数。 这与 Python 2.2 "
1085
+ "是一致的,在 Python 2.2 中,:class:`int`,:class:`str` 等也经历了同样的变化。"
1034
1086
1035
1087
#: ../../whatsnew/2.3.rst:966
1036
1088
msgid "Other Language Changes"
@@ -1071,12 +1123,14 @@ msgid ""
1071
1123
"that ``isinstance(int(expression), int)`` is false, but that seems unlikely "
1072
1124
"to cause problems in practice."
1073
1125
msgstr ""
1126
+ ":func:`int` 类型构造函数现在会返回一个长整数,而不会在字符串或浮点数太大而无法放入整数时引发 :exc:`OverflowError`。 "
1127
+ "这可能会导致 ``isinstance(int(expression), int)`` 为假的矛盾结果,但在实践中似乎不太可能造成问题。"
1074
1128
1075
1129
#: ../../whatsnew/2.3.rst:986
1076
1130
msgid ""
1077
1131
"Built-in types now support the extended slicing syntax, as described in "
1078
1132
"section :ref:`section-slices` of this document."
1079
- msgstr ""
1133
+ msgstr "内置类型现在支持扩展的切分语法,详见本文档 :ref:`section-slices` 一节。 "
1080
1134
1081
1135
#: ../../whatsnew/2.3.rst:989
1082
1136
msgid ""
@@ -1093,13 +1147,17 @@ msgid ""
1093
1147
"consistent with slice indexing, so when *pos* is -1 the value will be "
1094
1148
"inserted before the last element, and so forth."
1095
1149
msgstr ""
1150
+ "以前 ``list.insert(pos, value)`` 在 *pos* 为负值时会将 *value* 插入到列表的前面。 "
1151
+ "现在,该行为已被修改为与切片索引一致,因此当 *pos* 为 -1 时,值将被插入最后一个元素之前,以此类推。"
1096
1152
1097
1153
#: ../../whatsnew/2.3.rst:999
1098
1154
msgid ""
1099
1155
"``list.index(value)``, which searches for *value* within the list and "
1100
1156
"returns its index, now takes optional *start* and *stop* arguments to limit"
1101
1157
" the search to only part of the list."
1102
1158
msgstr ""
1159
+ "``list.index(value)`` 会在列表中搜索 *value*,并返回其索引,现在可以使用可选的 *start* 和 *stop* "
1160
+ "参数,将搜索范围限制在列表的一部分。"
1103
1161
1104
1162
#: ../../whatsnew/2.3.rst:1003
1105
1163
msgid ""
@@ -1108,13 +1166,18 @@ msgid ""
1108
1166
"dictionary. If the requested key isn't present in the dictionary, *default*"
1109
1167
" is returned if it's specified and :exc:`KeyError` raised if it isn't. ::"
1110
1168
msgstr ""
1169
+ "字典有一个新方法 ``pop(key[, *default*])``,可返回 *key* "
1170
+ "对应的值,并从字典中删除该键/值对。如果请求的键不在字典中,如果指定了 *default*,则返回 *default*,如果没有指定则会引发 "
1171
+ ":exc:`KeyError`。 ::"
1111
1172
1112
1173
#: ../../whatsnew/2.3.rst:1025
1113
1174
msgid ""
1114
1175
"There's also a new class method, ``dict.fromkeys(iterable, value)``, that "
1115
1176
"creates a dictionary with keys taken from the supplied iterator *iterable* "
1116
1177
"and all values set to *value*, defaulting to ``None``."
1117
1178
msgstr ""
1179
+ "还有一个新的类方法 ``dict.fromkeys(iterable, value)``,用于创建一个字典,其键取自所提供的迭代器 "
1180
+ "*iterable*,所有值设置为 *value*,默认为 ``None``。"
1118
1181
1119
1182
#: ../../whatsnew/2.3.rst:1029
1120
1183
msgid "(Patches contributed by Raymond Hettinger.)"
@@ -1158,13 +1221,18 @@ msgid ""
1158
1221
":option:`-Walways::PendingDeprecationWarning:: <-W>` on the command line or "
1159
1222
"use :func:`warnings.filterwarnings`."
1160
1223
msgstr ""
1224
+ "添加了一个新的警告 :exc:`PendingDeprecationWarning`,用于指示正在被废弃的功能。 默认情况下 *不会* 打印该警告。 "
1225
+ "要检查是否使用了将来会被废弃的功能,可在命令行中提供 :option:`-Walways::PendingDeprecationWarning:: "
1226
+ "<-W>` 或使用 :func:`warnings.filterwarnings`。"
1161
1227
1162
1228
#: ../../whatsnew/2.3.rst:1065
1163
1229
msgid ""
1164
1230
"The process of deprecating string-based exceptions, as in ``raise \" Error "
1165
1231
"occurred\" ``, has begun. Raising a string will now trigger "
1166
1232
":exc:`PendingDeprecationWarning`."
1167
1233
msgstr ""
1234
+ "与 ``raise \" Error occurred\" `` 一样,基于字符串的异常的废弃过程已经开始。 现在,引发字符串异常将触发 "
1235
+ ":exc:`PendingDeprecationWarning`。"
1168
1236
1169
1237
#: ../../whatsnew/2.3.rst:1069
1170
1238
msgid ""
@@ -1237,6 +1305,9 @@ msgid ""
1237
1305
"lines of those relating to assigning to an instance's "
1238
1306
":attr:`~instance.__class__` attribute."
1239
1307
msgstr ""
1308
+ "旧式和新式类之间的不兼容问题之一已被消除:您现在可以为新式类的 :attr:`~definition.__name__` 和 "
1309
+ ":attr:`~class.__bases__` 属性赋值。 对 :attr:`~class.__bases__` 的赋值有一些限制,与对实例的 "
1310
+ ":attr:`~instance.__class__` 属性的赋值类似。"
1240
1311
1241
1312
#: ../../whatsnew/2.3.rst:1125
1242
1313
msgid "String Changes"
@@ -1250,6 +1321,9 @@ msgid ""
1250
1321
"and ``X in Y`` will return :const:`True` if *X* is a substring of *Y*. If "
1251
1322
"*X* is the empty string, the result is always :const:`True`. ::"
1252
1323
msgstr ""
1324
+ ":keyword:`in` 运算符现在对字符串的作用不同了。 以前,当计算 ``X in Y`` 时,*X* 和 *Y* 都是字符串,*X* "
1325
+ "只能是单字符。 现在情况有所改变;*X* 可以是任意长度的字符串,如果 *X* 是 *Y* 的子串,``X in Y`` 将返回 "
1326
+ ":const:`True`。 如果 *X* 是空字符串,结果总是 :const:`True`。 ::"
1253
1327
1254
1328
#: ../../whatsnew/2.3.rst:1140
1255
1329
msgid ""
0 commit comments