@@ -529,6 +529,10 @@ msgid ""
529
529
"strange command-line flags or libraries that are required for a specific "
530
530
"platform."
531
531
msgstr ""
532
+ "不再需要编辑 :file:`Modules/Setup` 文件来启用模块,而是在 Python 源代码分发包的顶层目录运行一个 "
533
+ ":file:`setup.py` 脚本,该脚本在构建时尝试通过检查系统上的模块和头文件来发现可以启用那些模块。 如果某个模块已在 "
534
+ ":file:`Modules/Setup` 中配置,则 :file:`setup.py` 脚本不会尝试编译该模块,并会遵从 "
535
+ ":file:`Modules/Setup` 文件中的内容。 这提供了一种方式来指定特定平台所需的任何奇怪的命令行旗标或库。"
532
536
533
537
#: ../../whatsnew/2.1.rst:325
534
538
msgid ""
@@ -539,6 +543,9 @@ msgid ""
539
543
"subdirectories. This makes building Python faster and also makes hacking "
540
544
"the Makefiles clearer and simpler."
541
545
msgstr ""
546
+ "在对构建机制的另一项重大更改中,Neil Schemenauer 对其进行了重组,现在 Python 使用单一的非递归 "
547
+ "makefile,而不是在顶层目录和 :file:`Python/`、:file:`Parser/`、:file:`Objects/`和 "
548
+ ":file:`Modules/` 子目录中的多个 makefile。这使得构建 Python 更快,同时也使修改 Makefile 更加清晰和简单。"
542
549
543
550
#: ../../whatsnew/2.1.rst:335
544
551
msgid ":pep:`229` - Using Distutils to Build Python"
@@ -556,7 +563,7 @@ msgstr "PEP 205: 弱引用"
556
563
msgid ""
557
564
"Weak references, available through the :mod:`weakref` module, are a minor "
558
565
"but useful new data type in the Python programmer's toolbox."
559
- msgstr ""
566
+ msgstr "弱引用,通过 :mod:`weakref` 模块提供,是 Python 程序员工具箱中一种较小但有用的新数据类型。 "
560
567
561
568
#: ../../whatsnew/2.1.rst:347
562
569
msgid ""
@@ -566,13 +573,15 @@ msgid ""
566
573
"common one, and another being circular references in data structures such as"
567
574
" trees."
568
575
msgstr ""
576
+ "存储一个指向对象的引用(例如,在字典或列表中)会导致该对象永久存活。 "
577
+ "在某些特定情况下,这种行为是不符合需要的,最常见的是对象缓存,另一个是像树这样的数据结构中的循环引用。"
569
578
570
579
#: ../../whatsnew/2.1.rst:352
571
580
msgid ""
572
581
"For example, consider a memoizing function that caches the results of "
573
582
"another function ``f(x)`` by storing the function's argument and its result "
574
583
"in a dictionary::"
575
- msgstr ""
584
+ msgstr "例如,考虑一个记忆化函数,它通过将函数的参数及其结果存储在字典中来缓存另一个函数 ``f(x)`` 的结果:: "
576
585
577
586
#: ../../whatsnew/2.1.rst:368
578
587
msgid ""
@@ -594,6 +603,10 @@ msgid ""
594
603
"were a function: ``wr()``. It will return the referenced object, or "
595
604
"``None`` if the object no longer exists."
596
605
msgstr ""
606
+ "弱引用提供了一种实现缓存的方法,不会让对象在其生命周期结束后仍然存活。 "
607
+ "如果一个对象仅通过弱引用访问,该对象将被释放,并且弱引用将指示它所引用的对象不再存在。 通过调用 ``wr = weakref.ref(obj)`` "
608
+ "来创建对对象 *obj* 的弱引用。 通过调用弱引用,就像调用函数一样,可以返回被引用的对象: ``wr()``。 "
609
+ "如果对象仍然存在,它将返回被引用的对象;如果对象不再存在,则返回 ``None``。"
597
610
598
611
#: ../../whatsnew/2.1.rst:382
599
612
msgid ""
@@ -642,7 +655,7 @@ msgstr ""
642
655
msgid ""
643
656
"Arbitrary attributes can now be set and retrieved on functions using the "
644
657
"regular Python syntax::"
645
- msgstr ""
658
+ msgstr "现在可以使用常规的 Python 语法在函数上设置和检索任意属性:: "
646
659
647
660
#: ../../whatsnew/2.1.rst:444
648
661
msgid ""
@@ -673,6 +686,8 @@ msgid ""
673
686
"distinguish the filenames ``FILE.PY`` and ``file.py``, even though they do "
674
687
"store the file's name in its original case (they're case-preserving, too)."
675
688
msgstr ""
689
+ "一些操作系统的文件系统是大小写不敏感的,MacOS 和 Windows 是主要的例子;在这些系统上,无法区分文件名 ``FILE.PY`` 和 "
690
+ "``file.py``,尽管它们确实以原始大小写存储文件名(它们是保留大小写的)。"
676
691
677
692
#: ../../whatsnew/2.1.rst:468
678
693
msgid ""
@@ -684,6 +699,10 @@ msgid ""
684
699
":envvar:`PYTHONCASEOK` environment variable before starting the Python "
685
700
"interpreter."
686
701
msgstr ""
702
+ "在 Python 2.1 中,:keyword:`import` 语句可以在不区分大小写的平台上模拟大小写敏感性。 现在,Python "
703
+ "默认搜索第一个大小写敏感匹配的文件,如果找不到这样的文件,就会引发 :exc:`ImportError`,因此 ``import file`` "
704
+ "不会导入名为 ``FILE.PY`` 的模块。 在启动 Python 解释器之前,可以通过设置 :envvar:`PYTHONCASEOK` "
705
+ "环境变量来请求大小写不敏感匹配。"
687
706
688
707
#: ../../whatsnew/2.1.rst:479
689
708
msgid "PEP 217: Interactive Display Hook"
@@ -697,6 +716,9 @@ msgid ""
697
716
"be called instead of :func:`repr`. For example, you can set it to a special "
698
717
"pretty-printing function::"
699
718
msgstr ""
719
+ "在交互模式下使用 Python 解释器时,命令的输出是通过内置的 :func:`repr` 函数显示的。 在 Python 2.1 中,可以将变量 "
720
+ ":func:`sys.displayhook` 设置为一个可调用对象,该对象将在代替 :func:`repr` 函数被调用。 "
721
+ "例如,你可以将其设置为一个特殊的美化打印函数::"
700
722
701
723
#: ../../whatsnew/2.1.rst:502
702
724
msgid ":pep:`217` - Display Hook for Interactive Use"
@@ -716,6 +738,7 @@ msgid ""
716
738
"This will only affect the authors of C extensions to Python, allowing them "
717
739
"more flexibility in writing extension types that support numeric operations."
718
740
msgstr ""
741
+ "在 C 级别上的数值类型转换方法进行了重大修改。 这只会影响编写 Python C 扩展的作者,使他们在编写支持数值运算的扩展类型时有更多的灵活性。"
719
742
720
743
#: ../../whatsnew/2.1.rst:515
721
744
msgid ""
@@ -734,6 +757,12 @@ msgid ""
734
757
"not exist (perhaps raising a :exc:`TypeError`, perhaps trying another "
735
758
"object's numeric methods)."
736
759
msgstr ""
760
+ "扩展类型现在可以在其 ``PyTypeObject`` 结构中设置类型标志 "
761
+ "``Py_TPFLAGS_CHECKTYPES``,以表明它们支持新的强制模型。 "
762
+ "在此类扩展类型中,数字槽函数不再假定它们将得到两个相同类型的参数;相反,它们可能会得到两个不同类型的参数,然后可以执行自己的内部强制。如果槽函数传递给它一个无法处理的类型,它可以通过返回一个指向"
763
+ " ``Py_NotImplemented`` 单一值的引用来表示失败。 然后将尝试其他类型的数值函数,也许它们可以处理该操作;如果其他类型也返回 "
764
+ "``Py_NotImplemented``,那么将引发 :exc:`TypeError`。 用 Python 写的数值方法也可以返回 "
765
+ "``Py_NotImplemented``,导致解释器当作该方法不存在(也许会引发 :exc:`TypeError`,也许会尝试另一个对象的数值方法)。"
737
766
738
767
#: ../../whatsnew/2.1.rst:534
739
768
msgid ":pep:`208` - Reworking the Coercion Model"
@@ -745,6 +774,8 @@ msgid ""
745
774
" by Marc-André Lemburg. Read this to understand the fine points of how "
746
775
"numeric operations will now be processed at the C level."
747
776
msgstr ""
777
+ "由 Neil Schemenauer 编写和实现,基于 Marc-André Lemburg 的早期工作。阅读这部分内容可以了解数值运算在 C "
778
+ "级别上现在如何处理的细节。"
748
779
749
780
#: ../../whatsnew/2.1.rst:541
750
781
msgid "PEP 241: Metadata in Python Packages"
0 commit comments