@@ -447,6 +447,9 @@ msgid ""
447
447
"and Windows uses a two-character sequence of a carriage return plus a "
448
448
"newline."
449
449
msgstr ""
450
+ "目前使用的三大操作系统是微软的 Windows、苹果的 Macintosh OS 和各种 Unix "
451
+ "衍生系统。跨平台工作的一个小麻烦是,这三个平台都使用不同的字符来标记文本文件中的行结束。Unix 使用换行符(ASCII 字符 10),MacOS "
452
+ "使用回车符(ASCII 字符 13),Windows 使用回车符加换行符的双字符序列。"
450
453
451
454
#: ../../whatsnew/2.3.rst:384
452
455
msgid ""
@@ -472,6 +475,8 @@ msgid ""
472
475
":option:`!--without-universal-newlines` switch when running Python's "
473
476
":program:`configure` script."
474
477
msgstr ""
478
+ "在编译 Python 时,可以通过在运行 Python 的 :program:`configure` 脚本时指定 :option:`!--"
479
+ "without-universal-newlines` 开关禁用该功能。"
475
480
476
481
#: ../../whatsnew/2.3.rst:403
477
482
msgid ":pep:`278` - Universal Newline Support"
@@ -492,6 +497,9 @@ msgid ""
492
497
"sequence, returns an iterator that will return ``(0, thing[0])``, ``(1, "
493
498
"thing[1])``, ``(2, thing[2])``, and so forth."
494
499
msgstr ""
500
+ "新的内置函数 :func:`enumerate` 将使某些循环更加清晰。 在 ``enumerate(thing)`` 中,如果 *thing* "
501
+ "是迭代器或序列,则返回一个迭代器,该迭代器将返回 ``(0, thing[0])``,``(1, thing[1])``,``(2, "
502
+ "thing[2])``,以此类推。"
495
503
496
504
#: ../../whatsnew/2.3.rst:419
497
505
msgid "A common idiom to change every element of a list looks like this::"
@@ -524,6 +532,9 @@ msgid ""
524
532
"log, or even e-mail them to a particular address; of course, it's also "
525
533
"possible to write your own handler classes."
526
534
msgstr ""
535
+ "Python 2.3 中新增了一个用于编写日志的标准软件包 :mod:`logging`。 "
536
+ "它为生成日志输出提供了一个强大而灵活的机制,这些输出可以通过各种方式进行过滤和处理。用标准格式编写的配置文件可以用来控制程序的日志行为。 Python "
537
+ "包含的处理器可以将日志记录写入标准错误、文件或套接字,发送到系统日志,甚至通过电子邮件发送到特定地址;当然,您也可以编写自己的处理器类。"
527
538
528
539
#: ../../whatsnew/2.3.rst:453
529
540
msgid ""
@@ -609,6 +620,8 @@ msgid ""
609
620
"documentation for all of the details. Reading :pep:`282` will also be "
610
621
"helpful."
611
622
msgstr ""
623
+ ":mod:`logging` 软件包具有所有这些功能,即使是最复杂的应用程序也能灵活运用。 "
624
+ "本文仅是对其功能的不完整概述,因此请参阅软件包的参考文档了解所有细节。 阅读 :pep:`282` 也会有所帮助。"
612
625
613
626
#: ../../whatsnew/2.3.rst:541
614
627
msgid ":pep:`282` - A Logging System"
@@ -637,12 +650,14 @@ msgid ""
637
650
"for it takes any Python value and converts it to :const:`True` or "
638
651
":const:`False`. ::"
639
652
msgstr ""
653
+ "这个新类型的类型对象名为 :class:`bool`;它的构造函数接收任何 Python 值,并将其转换为 :const:`True` 或 "
654
+ ":const:`False`。::"
640
655
641
656
#: ../../whatsnew/2.3.rst:570
642
657
msgid ""
643
658
"Most of the standard library modules and built-in functions have been "
644
659
"changed to return Booleans. ::"
645
- msgstr ""
660
+ msgstr "大多数标准库模块和内置函数都改为返回布尔值: "
646
661
647
662
#: ../../whatsnew/2.3.rst:581
648
663
msgid ""
@@ -653,6 +668,8 @@ msgid ""
653
668
"the statement is ``return True``, however, the meaning of the return value "
654
669
"is quite clear."
655
670
msgstr ""
671
+ "添加 Python 布尔运算的主要目的是使代码更清晰。 例如,如果您在阅读一个函数时遇到 ``return 1`` 语句,您可能会想知道 ``1`` "
672
+ "代表的是布尔真值、索引还是乘以其他量的系数。 然而,如果语句是 ``return True``,返回值的含义就非常清楚了。"
656
673
657
674
#: ../../whatsnew/2.3.rst:587
658
675
msgid ""
@@ -666,6 +683,10 @@ msgid ""
666
683
" a subclass of the :class:`int` class so that arithmetic using a Boolean "
667
684
"still works. ::"
668
685
msgstr ""
686
+ "Python 的布尔值 *不是* 为了严格的类型检查而添加的。 像 Pascal 这样非常严格的语言也会阻止您使用布尔进行算术运算,并要求 "
687
+ ":keyword:`if` 语句中的表达式总是求布尔结果。 正如 :pep:`285` 所明确指出的,Python 没有这么严格,以后也不会有。 "
688
+ "这意味着您仍然可以在 :keyword:`!if` 语句中使用任何表达式,甚至是求值为 list、tuple 或一些随机对象的表达式。 布尔类型是 "
689
+ ":class:`int` 类的子类,因此使用布尔值进行算术运算仍然有效:"
669
690
670
691
#: ../../whatsnew/2.3.rst:605
671
692
msgid ""
@@ -674,6 +695,9 @@ msgid ""
674
695
"difference that :func:`str` and :func:`repr` return the strings ``'True'`` "
675
696
"and ``'False'`` instead of ``'1'`` and ``'0'``."
676
697
msgstr ""
698
+ "用一句话概括 :const:`True` 和 :const:`False`: 它们是拼写整数值 1 和 0 的另一种方式,唯一不同的是 "
699
+ ":func:`str` 和 :func:`repr` 返回的字符串是 ``'True'`` 和 ``'False'``,而不是 ``'1'`` 和 "
700
+ "``'0'``。"
677
701
678
702
#: ../../whatsnew/2.3.rst:613
679
703
msgid ":pep:`285` - Adding a bool type"
@@ -698,6 +722,9 @@ msgid ""
698
722
"inserting an XML character reference or HTML entity reference into the "
699
723
"converted string."
700
724
msgstr ""
725
+ "将 Unicode 字符串编码为字节字符串时,可能会遇到无法编码的字符。 到目前为止,Python 允许将错误处理指定为 \" strict\" (引发 "
726
+ ":exc:`UnicodeError`)、\" ignore\" (跳过该字符) 或 \" replace\" (在输出字符串中使用问号),其中 "
727
+ "\" strict\" 是默认行为。 可能需要指定对此类错误的其他处理方式,例如在转换后的字符串中插入 XML 字符引用或 HTML 实体引用。"
701
728
702
729
#: ../../whatsnew/2.3.rst:630
703
730
msgid ""
@@ -710,13 +737,18 @@ msgid ""
710
737
"target encoding. The handler can then either raise an exception or return a"
711
738
" replacement string."
712
739
msgstr ""
740
+ "Python 现在有一个灵活的框架,可以添加不同的处理策略。可以通过 :func:`codecs.register_error` "
741
+ "添加新的错误处理器,然后编解码器可以通过 :func:`codecs.lookup_error` 访问错误处理器。 "
742
+ "错误处理器会获取必要的状态信息,如正在转换的字符串、字符串中检测到错误的位置以及目标编码。 然后,处理器可以引发异常或返回替换字符串。"
713
743
714
744
#: ../../whatsnew/2.3.rst:638
715
745
msgid ""
716
746
"Two additional error handlers have been implemented using this framework: "
717
747
"\" backslashreplace\" uses Python backslash quoting to represent unencodable "
718
748
"characters and \" xmlcharrefreplace\" emits XML character references."
719
749
msgstr ""
750
+ "使用该框架还实现了两个额外的错误处理器: \" backslashreplace\" 使用 Python 反斜杠引号来表示无法编码的字符,而 "
751
+ "\" xmlcharrefreplace\" 则转换为 XML 字符引用。"
720
752
721
753
#: ../../whatsnew/2.3.rst:645
722
754
msgid ":pep:`293` - Codec Error Handling Callbacks"
@@ -760,7 +792,7 @@ msgstr ""
760
792
msgid ""
761
793
"Here's an example :file:`setup.py` with classifiers, written to be "
762
794
"compatible with older versions of the Distutils::"
763
- msgstr ""
795
+ msgstr "下面是一个带有分类器的 :file:`setup.py` 示例,其编写是为了兼容旧版本的 Distutils: "
764
796
765
797
#: ../../whatsnew/2.3.rst:688
766
798
msgid ""
@@ -805,12 +837,17 @@ msgid ""
805
837
"an importer object that will handle imports from this path or raises an "
806
838
":exc:`ImportError` exception if it can't handle this path."
807
839
msgstr ""
840
+ "``sys.path_hooks`` 是一个可调用对象列表,通常是类。 "
841
+ "每个可调用对象都接收一个包含路径的字符串,然后返回一个可处理从该路径导入的导入器对象,如果不能处理该路径,则引发 :exc:`ImportError` "
842
+ "异常。"
808
843
809
844
#: ../../whatsnew/2.3.rst:721
810
845
msgid ""
811
846
"``sys.path_importer_cache`` caches importer objects for each path, so "
812
847
"``sys.path_hooks`` will only need to be traversed once for each path."
813
848
msgstr ""
849
+ "``sys.path_importer_cache`` 会缓存每条路径的导入器对象,因此 ``sys.path_hooks`` 只需为每条路径遍历一次。"
850
+ " "
814
851
815
852
#: ../../whatsnew/2.3.rst:724
816
853
msgid ""
@@ -819,6 +856,8 @@ msgid ""
819
856
" can add objects to it. Additional built-in and frozen modules can be "
820
857
"imported by an object added to this list."
821
858
msgstr ""
859
+ "``sys.meta_path`` 是一个导入器对象列表,在检查 ``sys.path`` 之前将遍历该列表。 "
860
+ "该列表最初为空,但用户代码可以向其中添加对象。 其他内置模块和冻结模块可以通过添加到该列表中的对象导入。"
822
861
823
862
#: ../../whatsnew/2.3.rst:729
824
863
msgid ""
@@ -833,7 +872,7 @@ msgstr ""
833
872
msgid ""
834
873
"Pseudo-code for Python's new import logic, therefore, looks something like "
835
874
"this (simplified a bit; see :pep:`302` for the full details)::"
836
- msgstr ""
875
+ msgstr "因此,Python 新导入逻辑的伪代码如下 (略有简化;详情请参见 :pep:`302`): "
837
876
838
877
#: ../../whatsnew/2.3.rst:760
839
878
msgid ":pep:`302` - New Import Hooks"
@@ -869,7 +908,7 @@ msgstr "读取一行并调用 ``line.split(',')``: 再简单不过了吧? 但
869
908
msgid ""
870
909
"A big ugly regular expression can parse this, but using the new :mod:`csv` "
871
910
"package is much simpler::"
872
- msgstr ""
911
+ msgstr "一个大的丑陋的正则表达式可以解析这些内容,但使用新的 :mod:`csv` 软件包要简单得多: "
873
912
874
913
#: ../../whatsnew/2.3.rst:793
875
914
msgid ""
@@ -920,6 +959,9 @@ msgid ""
920
959
"format. A new constant, :const:`pickle.HIGHEST_PROTOCOL`, can be used to "
921
960
"select the fanciest protocol available."
922
961
msgstr ""
962
+ "解决办法就是发明一种新的 pickle 协议。 :func:`pickle.dumps` 函数很早就支持文本或二进制标志。 在 2.3 "
963
+ "中,该标志从布尔值重新定义为整数:0 表示旧的文本模式 pickle 格式,1 表示旧的二进制格式,现在 2 表示新的 2.3 专用格式。 一个新常量 "
964
+ ":const:`pickle.HIGHEST_PROTOCOL` 可用来选择最先进的协议。"
923
965
924
966
#: ../../whatsnew/2.3.rst:830
925
967
msgid ""
@@ -945,6 +987,8 @@ msgid ""
945
987
"Software Foundation will maintain a list of standardized codes; there's also"
946
988
" a range of codes for private use. Currently no codes have been specified."
947
989
msgstr ""
990
+ "为了进一步压缩 pickle 类,现在可以使用整数代码而不是长字符串来标识 pickle 类。 Python "
991
+ "软件基金会将维护一个标准化代码列表;还有一系列供私人使用的代码。 目前还没有指定任何代码。"
948
992
949
993
#: ../../whatsnew/2.3.rst:849
950
994
msgid ":pep:`307` - Extensions to the pickle protocol"
@@ -969,21 +1013,26 @@ msgid ""
969
1013
" if you tried it. Michael Hudson contributed a patch to fix this "
970
1014
"shortcoming."
971
1015
msgstr ""
1016
+ "从 Python 1.4 开始,切片语法支持可选的第三个“step”或“stride”参数。例如,这些都是合法的 Python 语法: "
1017
+ "``L[1:10:2]``,``L[:-1:1]``,``L[::-1]``。 这是应 Numerical Python 开发者的要求添加到 "
1018
+ "Python 中的,因为 Numerical Python 广泛使用第三个参数。 然而,Python 内置的 list、tuple "
1019
+ "和字符串序列类型从未支持过这一特性,如果您尝试使用,会引发 :exc:`TypeError`。 Michael Hudson "
1020
+ "提供了一个补丁来修复这一缺陷。"
972
1021
973
1022
#: ../../whatsnew/2.3.rst:868
974
1023
msgid ""
975
1024
"For example, you can now easily extract the elements of a list that have "
976
1025
"even indexes::"
977
- msgstr ""
1026
+ msgstr "例如,您现在可以轻松地提取出具有偶数索引的列表元素: "
978
1027
979
1028
#: ../../whatsnew/2.3.rst:875
980
1029
msgid ""
981
1030
"Negative values also work to make a copy of the same list in reverse order::"
982
- msgstr ""
1031
+ msgstr "也可以用负值以按相反顺序复制相同的列表: "
983
1032
984
1033
#: ../../whatsnew/2.3.rst:880
985
1034
msgid "This also works for tuples, arrays, and strings::"
986
- msgstr ""
1035
+ msgstr "这也适用于元组、数组和字符串: "
987
1036
988
1037
#: ../../whatsnew/2.3.rst:888
989
1038
msgid ""
@@ -992,17 +1041,18 @@ msgid ""
992
1041
"assignment to extended and regular slices. Assignment to a regular slice "
993
1042
"can be used to change the length of the sequence::"
994
1043
msgstr ""
1044
+ "如果你有一个可变序列如列表或数组,你可以对扩展切片进行赋值或删除,但对扩展切片的赋值与对常规切片的赋值有一些区别。对常规片段的赋值可以用来改变序列的长度:"
995
1045
996
1046
#: ../../whatsnew/2.3.rst:900
997
1047
msgid ""
998
1048
"Extended slices aren't this flexible. When assigning to an extended slice, "
999
1049
"the list on the right hand side of the statement must contain the same "
1000
1050
"number of items as the slice it is replacing::"
1001
- msgstr ""
1051
+ msgstr "扩展分片则没有这种灵活性。 在为扩展分片赋值时,语句右侧的列表必须包含与要替换的分片相同数量的项目: "
1002
1052
1003
1053
#: ../../whatsnew/2.3.rst:917
1004
1054
msgid "Deletion is more straightforward::"
1005
- msgstr ""
1055
+ msgstr "删除操作更为直观: "
1006
1056
1007
1057
#: ../../whatsnew/2.3.rst:928
1008
1058
msgid ""
@@ -1012,7 +1062,7 @@ msgstr ""
1012
1062
1013
1063
#: ../../whatsnew/2.3.rst:934
1014
1064
msgid "Or use slice objects directly in subscripts::"
1015
- msgstr ""
1065
+ msgstr "或者直接在下标中使用切片对象: "
1016
1066
1017
1067
#: ../../whatsnew/2.3.rst:939
1018
1068
msgid ""
0 commit comments