@@ -138,17 +138,18 @@ msgstr ""
138
138
139
139
#: ../../faq/design.rst:65
140
140
msgid ""
141
- "The :class:`float` type in CPython uses a C ``double`` for storage. A :"
142
- "class:`float` object's value is stored in binary floating-point with a fixed "
143
- "precision (typically 53 bits) and Python uses C operations, which in turn "
144
- "rely on the hardware implementation in the processor, to perform floating-"
145
- "point operations. This means that as far as floating-point operations are "
146
- "concerned, Python behaves like many popular languages including C and Java."
147
- msgstr ""
148
- "CPython 的 :class:`float` 型別使用了 C 的 ``double`` 型別來儲存。一個 :class:"
149
- "`float` 物件的值會以固定的精度(通常為 53 位元)存為二進制浮點數,Python 使"
150
- "用 C 來運算浮點數,而他的結果會依處理器中的硬體實作方式來決定。這表示就浮點數"
151
- "運算來說,Python 和 C、Java 等很多受歡迎的語言有一樣的行為。"
141
+ "The :class:`float` type in CPython uses a C ``double`` for storage. "
142
+ "A :class:`float` object's value is stored in binary floating-point with a "
143
+ "fixed precision (typically 53 bits) and Python uses C operations, which in "
144
+ "turn rely on the hardware implementation in the processor, to perform "
145
+ "floating-point operations. This means that as far as floating-point "
146
+ "operations are concerned, Python behaves like many popular languages "
147
+ "including C and Java."
148
+ msgstr ""
149
+ "CPython 的 :class:`float` 型別使用了 C 的 ``double`` 型別來儲存。一"
150
+ "個 :class:`float` 物件的值會以固定的精度(通常為 53 位元)存為二進制浮點數,"
151
+ "Python 使用 C 來運算浮點數,而他的結果會依處理器中的硬體實作方式來決定。這表"
152
+ "示就浮點數運算來說,Python 和 C、Java 等很多受歡迎的語言有一樣的行為。"
152
153
153
154
#: ../../faq/design.rst:72
154
155
msgid ""
@@ -249,11 +250,11 @@ msgid ""
249
250
"``m_`` prefix, so this explicitness is still useful in those languages, too."
250
251
msgstr ""
251
252
"第一,這樣可以更明顯表現出你在用方法 (method) 或是實例 (instance) 的屬性,而"
252
- "非一個區域變數。即使不知道類別 (class) 的定義,當看到 ``self.x`` 或 ``self. "
253
- "meth()``,就會很清楚地知道是正在使用實例的變數或是方法。在 C++ 裡,你可以藉由 "
254
- "沒有區域變數宣告來判斷這件事 ── 但在 Python 裡沒有區域變數宣告,所以你必須去 "
255
- "看類別的定義來確定 。有些 C++ 和 Java 的程式碼規格要求要在實例屬性的名稱加上前 "
256
- "綴 ``m_``,所以這種明確性在那些語言也是很好用的。"
253
+ "非一個區域變數。即使不知道類別 (class) 的定義,當看到 ``self.x`` 或 "
254
+ "``self. meth()``,就會很清楚地知道是正在使用實例的變數或是方法。在 C++ 裡,你 "
255
+ "可以藉由沒有區域變數宣告來判斷這件事 ── 但在 Python 裡沒有區域變數宣告,所以 "
256
+ "你必須去看類別的定義來確定 。有些 C++ 和 Java 的程式碼規格要求要在實例屬性的名 "
257
+ "稱加上前綴 ``m_``,所以這種明確性在那些語言也是很好用的。"
257
258
258
259
#: ../../faq/design.rst:127
259
260
msgid ""
@@ -353,12 +354,12 @@ msgstr ""
353
354
msgid ""
354
355
"(b) When I read code that says len(x) I *know* that it is asking for the "
355
356
"length of something. This tells me two things: the result is an integer, and "
356
- "the argument is some kind of container. To the contrary, when I read x. "
357
- "len(), I have to already know that x is some kind of container implementing "
358
- "an interface or inheriting from a class that has a standard len(). Witness "
359
- "the confusion we occasionally have when a class that is not implementing a "
360
- "mapping has a get() or keys() method, or something that isn't a file has a "
361
- "write() method."
357
+ "the argument is some kind of container. To the contrary, when I read "
358
+ "x. len(), I have to already know that x is some kind of container "
359
+ "implementing an interface or inheriting from a class that has a standard "
360
+ "len(). Witness the confusion we occasionally have when a class that is not "
361
+ "implementing a mapping has a get() or keys() method, or something that isn't "
362
+ "a file has a write() method."
362
363
msgstr ""
363
364
"(二) 當我看到一段程式碼寫著 len(x),我\\ *知道*\\ 他要找某個東西的長度。這"
364
365
"告訴了我兩件事:結果是一個整數、參數是某種容器。相對地,當我看到 x.len(),我"
@@ -419,8 +420,9 @@ msgstr ""
419
420
msgid ""
420
421
"The second objection is typically cast as: \" I am really telling a sequence "
421
422
"to join its members together with a string constant\" . Sadly, you aren't. "
422
- "For some reason there seems to be much less difficulty with having :meth:"
423
- "`~str.split` as a string method, since in that case it is easy to see that ::"
423
+ "For some reason there seems to be much less difficulty with "
424
+ "having :meth:`~str.split` as a string method, since in that case it is easy "
425
+ "to see that ::"
424
426
msgstr ""
425
427
"第二個反對意見通常是:「我是在叫一個序列把它的成員用一個字串常數連接起來」。"
426
428
"但很遺憾地,你並不是在這樣做。因為某種原因,把 :meth:`~str.split` 當成字串方"
@@ -544,8 +546,8 @@ msgstr ""
544
546
545
547
#: ../../faq/design.rst:279
546
548
msgid ""
547
- "For calling methods on objects, you can simplify yet further by using the : "
548
- "func:`getattr` built-in to retrieve methods with a particular name::"
549
+ "For calling methods on objects, you can simplify yet further by using "
550
+ "the : func:`getattr` built-in to retrieve methods with a particular name::"
549
551
msgstr ""
550
552
"對於呼叫物件裡的方法,你可以利用內建用來找尋特定方法的函式 :func:`getattr` 來"
551
553
"做進一步的簡化: ::"
@@ -818,10 +820,10 @@ msgstr ""
818
820
msgid ""
819
821
"Lists, on the other hand, are more like arrays in other languages. They "
820
822
"tend to hold a varying number of objects all of which have the same type and "
821
- "which are operated on one-by-one. For example, :func:`os.listdir('.') <os. "
822
- "listdir>` returns a list of strings representing the files in the current "
823
- "directory. Functions which operate on this output would generally not break "
824
- "if you added another file or two to the directory."
823
+ "which are operated on one-by-one. For example, :func:`os.listdir('.') "
824
+ "<os. listdir>` returns a list of strings representing the files in the "
825
+ "current directory. Functions which operate on this output would generally "
826
+ "not break if you added another file or two to the directory."
825
827
msgstr ""
826
828
"另一方面,串列更像是其他語言的陣列 (array)。他可以有不固定個同類別物件,且為"
827
829
"逐項操作。舉例來說,:func:`os.listdir('.') <os.listdir>` 回傳當下目錄裡的檔"
@@ -960,8 +962,8 @@ msgstr ""
960
962
msgid ""
961
963
"would raise a :exc:`KeyError` exception because the id of the ``[1, 2]`` "
962
964
"used in the second line differs from that in the first line. In other "
963
- "words, dictionary keys should be compared using ``==``, not using :keyword: "
964
- "`is`."
965
+ "words, dictionary keys should be compared using ``==``, not "
966
+ "using :keyword: `is`."
965
967
msgstr ""
966
968
"這將會導致 :exc:`KeyError` 例外,因為 ``[1, 2]`` 的 id 在第一行和第二行是不同"
967
969
"的。換句話說,字典的鍵應該要用 ``==`` 來做比較,而不是用 :keyword:`is`。"
@@ -1062,16 +1064,16 @@ msgstr ""
1062
1064
1063
1065
#: ../../faq/design.rst:534
1064
1066
msgid ""
1065
- "Furthermore it must always be the case that if ``o1 == o2`` (ie ``o1. "
1066
- "__eq__(o2) is True``) then ``hash(o1) == hash(o2)`` (ie, ``o1.__hash__() == "
1067
- "o2.__hash__()``), regardless of whether the object is in a dictionary or "
1068
- "not. If you fail to meet these restrictions dictionaries and other hash "
1069
- "based structures will misbehave."
1067
+ "Furthermore it must always be the case that if ``o1 == o2`` (ie "
1068
+ "``o1. __eq__(o2) is True``) then ``hash(o1) == hash(o2)`` (ie, "
1069
+ "``o1.__hash__() == o2.__hash__()``), regardless of whether the object is in "
1070
+ "a dictionary or not. If you fail to meet these restrictions dictionaries "
1071
+ "and other hash based structures will misbehave."
1070
1072
msgstr ""
1071
1073
"此外,不管物件是否在字典中,如果 ``o1 == o2``\\ (即 ``o1.__eq__(o2) is "
1072
- "True``),則 ``hash(o1) == hash(o2)``\\ (即 ``o1.__hash__() == o2. "
1073
- "__hash__()``),這個事實必須要成立。如果無法滿足這項限制,那字典和其他用雜湊 "
1074
- "為基底的結構會出現不正常的行為 。"
1074
+ "True``),則 ``hash(o1) == hash(o2)``\\ (即 ``o1.__hash__() == "
1075
+ "o2. __hash__()``),這個事實必須要成立。如果無法滿足這項限制,那字典和其他用雜 "
1076
+ "湊為基底的結構會出現不正常的行為 。"
1075
1077
1076
1078
#: ../../faq/design.rst:539
1077
1079
msgid ""
@@ -1136,16 +1138,17 @@ msgstr ""
1136
1138
msgid ""
1137
1139
"Python 2.6 adds an :mod:`abc` module that lets you define Abstract Base "
1138
1140
"Classes (ABCs). You can then use :func:`isinstance` and :func:`issubclass` "
1139
- "to check whether an instance or a class implements a particular ABC. The : "
1140
- "mod:`collections.abc` module defines a set of useful ABCs such as :class: "
1141
- "`~collections.abc.Iterable`, :class:`~collections.abc.Container`, and :class: "
1142
- "`~collections.abc.MutableMapping`."
1141
+ "to check whether an instance or a class implements a particular ABC. "
1142
+ "The : mod:`collections.abc` module defines a set of useful ABCs such "
1143
+ "as :class: `~collections.abc.Iterable`, :class:`~collections.abc.Container`, "
1144
+ "and :class: `~collections.abc.MutableMapping`."
1143
1145
msgstr ""
1144
1146
"Python 2.6 加入了 :mod:`abc` 模組,讓你可以定義抽象基底類別 (Abstract Base "
1145
1147
"Class, ABC)。你可以使用 :func:`isinstance` 和 :func:`issubclass` 來確認一個實"
1146
1148
"例或是類別是否實作了某個抽象基底類別。而 :mod:`collections.abc` 模組定義了一"
1147
- "系列好用的抽象基底類別,像是 :class:`~collections.abc.Iterable`、:class:"
1148
- "`~collections.abc.Container` 和 :class:`~collections.abc.MutableMapping`。"
1149
+ "系列好用的抽象基底類別,像"
1150
+ "是 :class:`~collections.abc.Iterable`、:class:`~collections.abc.Container` "
1151
+ "和 :class:`~collections.abc.MutableMapping`。"
1149
1152
1150
1153
#: ../../faq/design.rst:578
1151
1154
msgid ""
@@ -1159,12 +1162,12 @@ msgid ""
1159
1162
"as a module interface specification and a set of examples. Many Python "
1160
1163
"modules can be run as a script to provide a simple \" self test.\" Even "
1161
1164
"modules which use complex external interfaces can often be tested in "
1162
- "isolation using trivial \" stub\" emulations of the external interface. The : "
1163
- "mod:`doctest` and :mod:`unittest` modules or third-party test frameworks can "
1164
- "be used to construct exhaustive test suites that exercise every line of code "
1165
- "in a module."
1165
+ "isolation using trivial \" stub\" emulations of the external interface. "
1166
+ "The : mod:`doctest` and :mod:`unittest` modules or third-party test "
1167
+ "frameworks can be used to construct exhaustive test suites that exercise "
1168
+ "every line of code in a module."
1166
1169
msgstr ""
1167
- "一個針對模組的好測試套件提供了回歸測試 (regression testing),並作為模組介面規"
1170
+ "一個針對模組的好測試套件提供了迴歸測試 (regression testing),並作為模組介面規"
1168
1171
"範和一組範例。許多 Python 模組可以直接當成腳本執行,並提供簡單的「自我測"
1169
1172
"試」。即便模組使用了複雜的外部介面,他依然可以用外部介面的簡單的「樁」(stub) "
1170
1173
"模擬來獨立測試。:mod:`doctest` 和 :mod:`unittest` 模組或第三方的測試框架可以"
@@ -1209,16 +1212,16 @@ msgid ""
1209
1212
"\" spaghetti\" code that was hard to understand and revise. In a high-level "
1210
1213
"language, it is also unneeded as long as there are ways to branch (in "
1211
1214
"Python, with :keyword:`if` statements and :keyword:`or`, :keyword:`and`, "
1212
- "and :keyword:`if`/:keyword:`else` expressions) and loop (with :keyword: "
1213
- "`while` and :keyword:`for` statements, possibly containing :keyword: "
1214
- "`continue` and :keyword:`break`)."
1215
+ "and :keyword:`if`/:keyword:`else` expressions) and loop "
1216
+ "(with :keyword: `while` and :keyword:`for` statements, possibly "
1217
+ "containing :keyword: `continue` and :keyword:`break`)."
1215
1218
msgstr ""
1216
1219
"在 1970 年代,人們了解到沒有限制的 goto 會導致混亂、難以理解和修改的「義大利"
1217
1220
"麵」程式碼 (\" spaghetti\" code)。在高階語言裡,這也是不需要的,因為有方法可以"
1218
- "做邏輯分支(以 Python 來說,用 :keyword:`if` 陳述式和 :keyword:`or`、: "
1219
- "keyword:`and` 及 :keyword:`if`/:keyword:`else` 運算式)和迴圈(用 :keyword: "
1220
- "`while` 和 :keyword:`for` 陳述式,可能會有 :keyword:`continue` 和 :keyword: "
1221
- "`break`)。"
1221
+ "做邏輯分支(以 Python 來說,用 :keyword:`if` 陳述式 "
1222
+ "和 : keyword:`or`、:keyword:` and` 及 :keyword:`if`/:keyword:`else` 運算式)和 "
1223
+ "迴圈(用 :keyword: `while` 和 :keyword:`for` 陳述式,可能會 "
1224
+ "有 :keyword:`continue` 和 :keyword: `break`)。"
1222
1225
1223
1226
#: ../../faq/design.rst:614
1224
1227
msgid ""
@@ -1437,14 +1440,14 @@ msgstr "為何產生器 (generator) 不支援 with 陳述式?"
1437
1440
msgid ""
1438
1441
"For technical reasons, a generator used directly as a context manager would "
1439
1442
"not work correctly. When, as is most common, a generator is used as an "
1440
- "iterator run to completion, no closing is needed. When it is, wrap it as : "
1441
- "func:`contextlib.closing(generator) <contextlib.closing>` in the :keyword: "
1442
- "`with` statement."
1443
+ "iterator run to completion, no closing is needed. When it is, wrap it "
1444
+ "as : func:`contextlib.closing(generator) <contextlib.closing>` in "
1445
+ "the :keyword: `with` statement."
1443
1446
msgstr ""
1444
1447
"出於技術原因,把產生器直接用作情境 (context) 管理器會無法正常運作。因為通常來"
1445
1448
"說,產生器是被當成疊代器 (iterator),到最後完成時不需要被手動關閉。但如果你需"
1446
- "要的話,你可以在 :keyword:`with` 陳述式裡用 :func:`contextlib. "
1447
- "closing(generator) <contextlib.closing>` 來包裝他。"
1449
+ "要的話,你可以在 :keyword:`with` 陳述式裡 "
1450
+ "用 :func:`contextlib. closing(generator) <contextlib.closing>` 來包裝他。"
1448
1451
1449
1452
#: ../../faq/design.rst:730
1450
1453
msgid "Why are colons required for the if/while/def/class statements?"
0 commit comments