77# Yinuo Huang <[email protected] >, 201888# ww song <[email protected] >, 201899# Freesand Leo <[email protected] >, 201910- # tom smith, 2019
1110# Shengjing Zhu <[email protected] >, 201911+ # Meng Du <[email protected] >, 201912+ # tom smith, 2019
1213#
1314#, fuzzy
1415msgid ""
@@ -17,7 +18,7 @@ msgstr ""
1718"Report-Msgid-Bugs-To : \n "
1819"POT-Creation-Date : 2019-01-01 10:14+0900\n "
1920"PO-Revision-Date : 2017-02-16 17:42+0000\n "
20- "
Last-Translator :
Shengjing Zhu <[email protected] > , 2019\n"
21+ "Last-Translator : tom smith , 2019\n "
2122"Language-Team : Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n "
2223"MIME-Version : 1.0\n "
2324"Content-Type : text/plain; charset=UTF-8\n "
@@ -254,20 +255,20 @@ msgstr "许多习惯于C或Perl的人抱怨,他们想要使用C 的这个特
254255
255256#: ../../faq/design.rst:160
256257msgid "where in Python you're forced to write this::"
257- msgstr "但在Python中被强制写成这样: "
258+ msgstr "但在Python中被强制写成这样:: "
258259
259260#: ../../faq/design.rst:168
260261msgid ""
261262"The reason for not allowing assignment in Python expressions is a common, "
262263"hard-to-find bug in those other languages, caused by this construct:"
263- msgstr "不允许在python表达式中赋值的原因是这些其他语言中常见的 、很难发现的错误,是由这个结构引起的:"
264+ msgstr "不允许在 Python 表达式中赋值的原因是这些其他语言中常见的 、很难发现的错误,是由这个结构引起的:"
264265
265266#: ../../faq/design.rst:180
266267msgid ""
267268"The error is a simple typo: ``x = 0``, which assigns 0 to the variable "
268269"``x``, was written while the comparison ``x == 0`` is certainly what was "
269270"intended."
270- msgstr "错误是一个简单的错字:``x = 0``,将0赋给变量``x``,而比较``x == 0``肯定是可以预期的。"
271+ msgstr "错误是一个简单的错字: ``x = 0`` ,将0赋给变量 ``x`` ,而比较 ``x == 0`` 肯定是可以预期的。"
271272
272273#: ../../faq/design.rst:183
273274msgid ""
@@ -303,7 +304,7 @@ msgid ""
303304" you have to remember to change two places in your program -- the second "
304305"occurrence is hidden at the bottom of the loop."
305306msgstr ""
306- "问题在于,如果你改变主意(例如你想把它改成``sys.stdin.readline()``),如何知道下一行。你必须记住改变程序中的两个地方 -- "
307+ "问题在于,如果你改变主意(例如你想把它改成 ``sys.stdin.readline()`` ),如何知道下一行。你必须记住改变程序中的两个地方 -- "
307308"第二次出现隐藏在循环的底部。"
308309
309310#: ../../faq/design.rst:206
@@ -333,8 +334,8 @@ msgid ""
333334"problem. Compare the easy with which we rewrite a formula like x*(a+b) into "
334335"x*a + x*b to the clumsiness of doing the same thing using a raw OO notation."
335336msgstr ""
336- "(a) 对于某些操作,前缀表示法比后缀更容易阅读 -- "
337- "前缀(和中缀!)运算在数学中有着悠久的传统,就像在视觉上帮助数学家思考问题的记法。比较一下我们将x*( a+b)这样的公式改写为x *a+x*b的容易程度 ,以及使用原始OO符号做相同事情的笨拙程度。"
337+ "(a) 对于某些操作,前缀表示法比后缀更容易阅读 -- 前缀(和中缀!)运算在数学中有着悠久的传统,就像在视觉上帮助数学家思考问题的记法。比较一下我们将 "
338+ " x*( a+b) 这样的公式改写为 x *a+x*b 的容易程度 ,以及使用原始OO符号做相同事情的笨拙程度。"
338339
339340#: ../../faq/design.rst:227
340341msgid ""
@@ -405,7 +406,7 @@ msgstr ""
405406msgid ""
406407"is an instruction to a string literal to return the substrings delimited by "
407408"the given separator (or, by default, arbitrary runs of white space)."
408- msgstr "是对字符串文本的指令,用于返回由给定分隔符分隔的子字符串( 或在默认情况下,返回任意空格) 。"
409+ msgstr "是对字符串文本的指令,用于返回由给定分隔符分隔的子字符串( 或在默认情况下,返回任意空格) 。"
409410
410411#: ../../faq/design.rst:272
411412msgid ""
@@ -420,27 +421,29 @@ msgstr ""
420421
421422#: ../../faq/design.rst:280
422423msgid "How fast are exceptions?"
423- msgstr ""
424+ msgstr "异常有多快? "
424425
425426#: ../../faq/design.rst:282
426427msgid ""
427428"A try/except block is extremely efficient if no exceptions are raised. "
428429"Actually catching an exception is expensive. In versions of Python prior to"
429430" 2.0 it was common to use this idiom::"
430- msgstr ""
431+ msgstr "如果没有引发异常,则try/except块的效率极高。实际上捕获异常是昂贵的。在2.0之前的Python版本中,通常使用这个习惯用法:: "
431432
432433#: ../../faq/design.rst:292
433434msgid ""
434435"This only made sense when you expected the dict to have the key almost all "
435436"the time. If that wasn't the case, you coded it like this::"
436- msgstr ""
437+ msgstr "只有当你期望dict在任何时候都有key时,这才有意义。如果不是这样的话,你就是应该这样编码: "
437438
438439#: ../../faq/design.rst:300
439440msgid ""
440441"For this specific case, you could also use ``value = dict.setdefault(key, "
441442"getvalue(key))``, but only if the ``getvalue()`` call is cheap enough "
442443"because it is evaluated in all cases."
443444msgstr ""
445+ "对于这种特定的情况,您还可以使用 ``value = dict.setdefault(key, "
446+ "getvalue(key))``,但前提是调用``getvalue()`` 足够便宜,因为在所有情况下都会对其进行评估。"
444447
445448#: ../../faq/design.rst:306
446449msgid "Why isn't there a switch or case statement in Python?"
@@ -453,33 +456,36 @@ msgid ""
453456"there is no consensus (yet) on whether and how to do range tests. See "
454457":pep:`275` for complete details and the current status."
455458msgstr ""
459+ "你可以通过一系列 ``if... elif... elif... "
460+ "else``.轻松完成这项工作。对于switch语句语法已经有了一些建议,但尚未就是否以及如何进行范围测试达成共识。有关完整的详细信息和当前状态,请参阅"
461+ " :pep:`275` 。 "
456462
457463#: ../../faq/design.rst:313
458464msgid ""
459465"For cases where you need to choose from a very large number of "
460466"possibilities, you can create a dictionary mapping case values to functions "
461467"to call. For example::"
462- msgstr ""
468+ msgstr "对于需要从大量可能性中进行选择的情况,可以创建一个字典,将case 值映射到要调用的函数。例如: "
463469
464470#: ../../faq/design.rst:327
465471msgid ""
466472"For calling methods on objects, you can simplify yet further by using the "
467473":func:`getattr` built-in to retrieve methods with a particular name::"
468- msgstr ""
474+ msgstr "对于对象调用方法,可以通过使用 :func:`getattr` 内置检索具有特定名称的方法来进一步简化: "
469475
470476#: ../../faq/design.rst:339
471477msgid ""
472478"It's suggested that you use a prefix for the method names, such as "
473479"``visit_`` in this example. Without such a prefix, if values are coming "
474480"from an untrusted source, an attacker would be able to call any method on "
475481"your object."
476- msgstr ""
482+ msgstr "建议对方法名使用前缀,例如本例中的 ``visit_`` 。如果没有这样的前缀,如果值来自不受信任的源,攻击者将能够调用对象上的任何方法。 "
477483
478484#: ../../faq/design.rst:345
479485msgid ""
480486"Can't you emulate threads in the interpreter instead of relying on an OS-"
481487"specific thread implementation?"
482- msgstr ""
488+ msgstr "难道不能在解释器中模拟线程,而非得依赖特定于操作系统的线程实现吗? "
483489
484490#: ../../faq/design.rst:347
485491msgid ""
@@ -488,13 +494,16 @@ msgid ""
488494"almost random moments. Therefore, a complete threads implementation "
489495"requires thread support for C."
490496msgstr ""
497+ "答案1: 不幸的是,解释器为每个Python堆栈帧推送至少一个C堆栈帧。此外,扩展几乎随时回调Python。因此,一个完整的线程实现需要对C的线程支持。"
491498
492499#: ../../faq/design.rst:352
493500msgid ""
494501"Answer 2: Fortunately, there is `Stackless Python <https://github.com"
495502"/stackless-dev/stackless/wiki>`_, which has a completely redesigned "
496503"interpreter loop that avoids the C stack."
497504msgstr ""
505+ "答案2: 幸运的是, `Stackless Python <https://github.com/stackless-"
506+ "dev/stackless/wiki>`_ 有一个完全重新设计的解释器循环,可以避免C堆栈。"
498507
499508#: ../../faq/design.rst:357
500509msgid "Why can't lambda expressions contain statements?"
@@ -508,6 +517,9 @@ msgid ""
508517"other languages, where they add functionality, Python lambdas are only a "
509518"shorthand notation if you're too lazy to define a function."
510519msgstr ""
520+ "Python的 "
521+ "lambda表达式不能包含语句,因为Python的语法框架不能处理嵌套在表达式内部的语句。然而,在Python中,这并不是一个严重的问题。与其他语言中添加功能的lambda表单不同,Python的"
522+ " lambdas只是一种速记符号,如果您懒得定义函数的话。"
511523
512524#: ../../faq/design.rst:365
513525msgid ""
@@ -518,6 +530,8 @@ msgid ""
518530"(which is exactly the same type of object that a lambda expression yields) "
519531"is assigned!"
520532msgstr ""
533+ "函数已经是Python中的第一类对象,可以在本地范围内声明。 因此,使用lambda而不是本地定义的函数的唯一优点是你不需要为函数创建一个名称 -- "
534+ "这只是一个分配了函数对象(与lambda表达式生成的对象类型完全相同)的局部变量!"
521535
522536#: ../../faq/design.rst:373
523537msgid "Can Python be compiled to machine code, C or some other language?"
@@ -531,6 +545,9 @@ msgid ""
531545"full Python language. For compiling to Java you can consider `VOC "
532546"<https://voc.readthedocs.io>`_."
533547msgstr ""
548+ "`Cython <http://cython.org/>`_ 将带有可选注释的Python修改版本编译到C扩展中。 `Nuitka "
549+ "<http://www.nuitka.net/>`_ 是一个将Python编译成 C++ "
550+ "代码的新兴编译器,旨在支持完整的Python语言。要编译成Java,可以考虑 `VOC <https://voc.readthedocs.io>`_ 。"
534551
535552#: ../../faq/design.rst:383
536553msgid "How does Python manage memory?"
@@ -546,6 +563,9 @@ msgid ""
546563"provides functions to perform a garbage collection, obtain debugging "
547564"statistics, and tune the collector's parameters."
548565msgstr ""
566+ "Python内存管理的细节取决于实现。Python的标准实现 "
567+ ":term:`CPython`使用引用计数来检测不可访问的对象,并使用另一种机制来收集引用循环,定期执行循环检测算法来查找不可访问的循环并删除所涉及的对象。"
568+ " :mod:`gc` 模块提供了执行垃圾收集、获取调试统计信息和优化收集器参数的函数"
549569
550570#: ../../faq/design.rst:393
551571msgid ""
@@ -555,12 +575,15 @@ msgid ""
555575"porting problems if your Python code depends on the behavior of the "
556576"reference counting implementation."
557577msgstr ""
578+ "但是,其他实现(如 `Jython <http://www.jython.org>`_ 或 `PyPy "
579+ "<http://www.pypy.org>`_ ),)可以依赖不同的机制,如完全的垃圾回收器 "
580+ "。如果你的Python代码依赖于引用计数实现的行为,则这种差异可能会导致一些微妙的移植问题。"
558581
559582#: ../../faq/design.rst:399
560583msgid ""
561584"In some Python implementations, the following code (which is fine in "
562585"CPython) will probably run out of file descriptors::"
563- msgstr ""
586+ msgstr "在一些Python实现中,以下代码(在CPython中工作的很好)可能会耗尽文件描述符:: "
564587
565588#: ../../faq/design.rst:406
566589msgid ""
@@ -569,13 +592,16 @@ msgid ""
569592" those file objects will only get collected (and closed) at varying and "
570593"possibly long intervals."
571594msgstr ""
595+ "实际上,使用CPython的引用计数和析构函数方案, 每个新赋值的*f* "
596+ "都会关闭前一个文件。然而,对于传统的GC,这些文件对象只能以不同的时间间隔(可能很长的时间间隔)被收集(和关闭)。"
572597
573598#: ../../faq/design.rst:411
574599msgid ""
575600"If you want to write code that will work with any Python implementation, you"
576601" should explicitly close the file or use the :keyword:`with` statement; this"
577602" will work regardless of memory management scheme::"
578603msgstr ""
604+ "如果要编写可用于任何python实现的代码,则应显式关闭该文件或使用 :keyword:`with` 语句;无论内存管理方案如何,这都有效:"
579605
580606#: ../../faq/design.rst:421
581607msgid "Why doesn't CPython use a more traditional garbage collection scheme?"
@@ -589,6 +615,8 @@ msgid ""
589615"transparent, it isn't completely transparent; patches are required to get "
590616"Python to work with it.)"
591617msgstr ""
618+ "首先,这不是C标准特性,因此不能移植。(是的,我们知道Boehm "
619+ "GC库。它包含了*大多数*常见平台(但不是所有平台)的汇编代码,尽管它基本上是透明的,但也不是完全透明的; 要让Python使用它,需要使用补丁。)"
592620
593621#: ../../faq/design.rst:429
594622msgid ""
@@ -599,6 +627,8 @@ msgid ""
599627"malloc() and free(), and may not want Python's. Right now, CPython works "
600628"with anything that implements malloc() and free() properly."
601629msgstr ""
630+ "当Python嵌入到其他应用程序中时,传统的GC也成为一个问题。在独立的Python中,可以用GC库提供的版本替换标准的malloc()和free(),嵌入Python的应用程序可能希望用"
631+ " *它自己* 替代malloc()和free(),而可能不需要Python的。现在,CPython可以正确地实现malloc()和free()。"
602632
603633#: ../../faq/design.rst:438
604634msgid "Why isn't all memory freed when CPython exits?"
0 commit comments