@@ -235,7 +235,6 @@ msgstr ""
235
235
"綴 ``m_``,所以這種明確性在那些語言也是很好用的。"
236
236
237
237
#: ../../faq/design.rst:127
238
- #, fuzzy
239
238
msgid ""
240
239
"Second, it means that no special syntax is necessary if you want to "
241
240
"explicitly reference or call the method from a particular class. In C++, if "
@@ -249,8 +248,8 @@ msgstr ""
249
248
"第二,當你想明確地使用或呼叫在某個類別裡的方法的時候,你不需要特殊的語法。在 "
250
249
"C++ 裡,如果你想用一個在繼承類別時被覆寫的基底類別方法,必須要用 ``::`` 運算"
251
250
"子 -- 但在 Python 裡,你可以直接寫成 ``baseclass.methodname(self, <argument "
252
- "list>)``。這在 :meth:`__init__` 方法很好用,特別是在一個繼承的類別要擴充基底 "
253
- "類別的方法而要呼叫他時 。"
251
+ "list>)``。這在 :meth:`~object. __init__` 方法很好用,特別是在一個繼承的類別要 "
252
+ "擴充基底類別的方法而要呼叫他時 。"
254
253
255
254
#: ../../faq/design.rst:136
256
255
msgid ""
@@ -425,14 +424,14 @@ msgid "How fast are exceptions?"
425
424
msgstr "例外處理有多快?"
426
425
427
426
#: ../../faq/design.rst:235
428
- #, fuzzy
429
427
msgid ""
430
428
"A :keyword:`try`/:keyword:`except` block is extremely efficient if no "
431
429
"exceptions are raised. Actually catching an exception is expensive. In "
432
430
"versions of Python prior to 2.0 it was common to use this idiom::"
433
431
msgstr ""
434
- "如果沒有例外被丟出,一個 try/except 區塊是非常有效率的。事實上,抓捕例外要付"
435
- "出昂貴的代價。在 Python 2.0 以前,這樣使用是相當常見的:\n"
432
+ "如果沒有例外被丟出,一個 :keyword:`try`/:keyword:`except` 區塊是非常有效率"
433
+ "的。事實上,抓捕例外要付出昂貴的代價。在 Python 2.0 以前,這樣使用是相當常見"
434
+ "的:\n"
436
435
"\n"
437
436
"::"
438
437
@@ -613,16 +612,15 @@ msgstr ""
613
612
"::"
614
613
615
614
#: ../../faq/design.rst:355
616
- #, fuzzy
617
615
msgid ""
618
616
"Indeed, using CPython's reference counting and destructor scheme, each new "
619
617
"assignment to ``f`` closes the previous file. With a traditional GC, "
620
618
"however, those file objects will only get collected (and closed) at varying "
621
619
"and possibly long intervals."
622
620
msgstr ""
623
- "實際上,使用 CPython 的參照計次和解構方案 (destructor scheme),每個對\\ "
624
- "*f* \\ 的新指派都會關閉前面打開的檔案。然而用傳統的垃圾回收 (GC) 的話,這些檔 "
625
- "案物件只會在不固定且有可能很長的時間後被收集 (並關閉)。"
621
+ "實際上,使用 CPython 的參照計次和解構方案 (destructor scheme),每個對 ``f`` "
622
+ "的新指派都會關閉前面打開的檔案。然而用傳統的垃圾回收 (GC) 的話,這些檔案物件 "
623
+ "只會在不固定且有可能很長的時間後被收集 (並關閉)。"
626
624
627
625
#: ../../faq/design.rst:360
628
626
msgid ""
@@ -653,7 +651,6 @@ msgstr ""
653
651
"大多數是通透的,也並不完全,要讓它跟 Python 相容還是需要做一些修補。)"
654
652
655
653
#: ../../faq/design.rst:378
656
- #, fuzzy
657
654
msgid ""
658
655
"Traditional GC also becomes a problem when Python is embedded into other "
659
656
"applications. While in a standalone Python it's fine to replace the "
@@ -664,10 +661,10 @@ msgid ""
664
661
"``free()`` properly."
665
662
msgstr ""
666
663
"傳統的垃圾收集 (GC) 在 Python 被嵌入其他應用程式時也成了一個問題。在獨立的 "
667
- "Python 程式裡當然可以把標準的 malloc() 和 free() 換成 GC函式庫提供的其他版 "
668
- "本 ;但一個嵌著 Python 的應用程式可能想用\\ *自己*\\ 的 malloc() 和free() 替 "
669
- "代品 ,而不是用 Python 的。以現在來說,CPython 和實作 malloc() 和free() 的程 "
670
- "式相處融洽 。"
664
+ "Python 程式裡當然可以把標準的`` malloc()`` 和`` free()`` 換成 GC函式庫提供的 "
665
+ "其他版本 ;但一個嵌著 Python 的應用程式可能想用\\ *自己*\\ 的 malloc() 和 "
666
+ "free() 替代品 ,而不是用 Python 的。以現在來說,CPython 和實作 malloc() 和 "
667
+ "free() 的程式相處融洽 。"
671
668
672
669
#: ../../faq/design.rst:387
673
670
msgid "Why isn't all memory freed when CPython exits?"
@@ -700,7 +697,6 @@ msgid "Why are there separate tuple and list data types?"
700
697
msgstr "為何要把元組 (tuple) 和串列 (list) 分成兩個資料型態?"
701
698
702
699
#: ../../faq/design.rst:403
703
- #, fuzzy
704
700
msgid ""
705
701
"Lists and tuples, while similar in many respects, are generally used in "
706
702
"fundamentally different ways. Tuples can be thought of as being similar to "
@@ -710,12 +706,11 @@ msgid ""
710
706
"two or three numbers."
711
707
msgstr ""
712
708
"串列和元組在很多方面相當相似,但通常用在完全不同的地方。元組可以想成 Pascal "
713
- "的紀錄 ( record) 或是 C的結構 ( struct),是一小群相關聯但可能是不同型別的資料 "
714
- "集合 ,以一組為單位進行操作。舉例來說,一個笛卡兒坐標系可以適當地表示成一個有 "
715
- "二或三個值的元組 。"
709
+ "的 `` record`` 或是 C的 `` struct``,是一小群相關聯但可能是不同型別的資料集 "
710
+ "合 ,以一組為單位進行操作。舉例來說,一個笛卡兒坐標系可以適當地表示成一個有二 "
711
+ "或三個值的元組 。"
716
712
717
713
#: ../../faq/design.rst:410
718
- #, fuzzy
719
714
msgid ""
720
715
"Lists, on the other hand, are more like arrays in other languages. They "
721
716
"tend to hold a varying number of objects all of which have the same type and "
@@ -725,8 +720,9 @@ msgid ""
725
720
"if you added another file or two to the directory."
726
721
msgstr ""
727
722
"另一方面,串列更像是其他語言的陣列 (array)。他可以有不固定個同類別物件,且為"
728
- "逐項操作。舉例來說,``os.listdir('.')`` 回傳當下目錄裡的檔案,以包含字串的串"
729
- "列表示。如果你新增了幾個檔案到這個目錄,一般來說操作結果的函式也會正常運作。"
723
+ "逐項操作。舉例來說,:func:`os.listdir('.') <os.listdir>` 回傳當下目錄裡的檔"
724
+ "案,以包含字串的串列表示。如果你新增了幾個檔案到這個目錄,一般來說操作結果的"
725
+ "函式也會正常運作。"
730
726
731
727
#: ../../faq/design.rst:418
732
728
msgid ""
@@ -787,7 +783,6 @@ msgstr ""
787
783
"tree),在搜尋(目前為止最常見的操作)方面有更好的表現,實作上也較為簡單。"
788
784
789
785
#: ../../faq/design.rst:447
790
- #, fuzzy
791
786
msgid ""
792
787
"Dictionaries work by computing a hash code for each key stored in the "
793
788
"dictionary using the :func:`hash` built-in function. The hash code varies "
@@ -800,10 +795,10 @@ msgid ""
800
795
"notation -- to retrieve a key."
801
796
msgstr ""
802
797
"字典利用內建 :func:`hash` 函式,對每個鍵做雜湊計算。雜湊結果依據鍵的值和個別"
803
- "執行緒 (processes) 的種子而有相當大的差距。例如,\" Python\" 的雜湊是 "
804
- "-539294296,而只差一個字的\" python\" 則是 1142331976。雜湊結果接著被用來計算 "
805
- "值在內部陣列儲存的位置 。假設你存的鍵都有不同的雜湊值,那字典只需要常數時間 — "
806
- "用大 O 表示法 (Big-O notation) 就是 O(1) — 來找任意一個鍵。"
798
+ "執行緒 (processes) 的種子而有相當大的差距。例如,``' Python'`` 的雜湊是 "
799
+ "`` -539294296`` ,而只差一個字的``' python'`` 則是`` 1142331976``。雜湊結果接著 "
800
+ "被用來計算值在內部陣列儲存的位置 。假設你存的鍵都有不同的雜湊值,那字典只需要 "
801
+ "常數時間 — 用大 O 表示法 (Big-O notation) 就是 O(1) — 來找任意一個鍵。"
807
802
808
803
#: ../../faq/design.rst:458
809
804
msgid "Why must dictionary keys be immutable?"
@@ -895,7 +890,6 @@ msgstr ""
895
890
"所有物件都標記成只能讀取 — 所以再一次,自己參照自己的物件會導致無窮迴圈。"
896
891
897
892
#: ../../faq/design.rst:500
898
- #, fuzzy
899
893
msgid ""
900
894
"There is a trick to get around this if you need to, but use it at your own "
901
895
"risk: You can wrap a mutable structure inside a class instance which has "
@@ -905,9 +899,9 @@ msgid ""
905
899
"the object is in the dictionary (or other structure). ::"
906
900
msgstr ""
907
901
"如果你需要的話,這裡有個小技巧可以幫你,但請自己承擔風險:你可以把一個可變物"
908
- "件包裝進一個有 :meth:`__eq__` 和 :meth:`__hash__`方法的類別實例。只要這種包 "
909
- "裝物件還存在於字典 (或其他類似結構)中,你就必須確定在字典(或其他用雜湊為基 "
910
- "底的結構 )中他們的雜湊值會保持恆定。\n"
902
+ "件包裝進一個有 :meth:`~object. __eq__` 和 :meth:`~object. __hash__`方法的類別 "
903
+ "實例。只要這種包裝物件還存在於字典 (或其他類似結構)中,你就必須確定在字典"
904
+ "(或其他用雜湊為基底的結構 )中他們的雜湊值會保持恆定。\n"
911
905
"\n"
912
906
"::"
913
907
@@ -934,16 +928,15 @@ msgstr ""
934
928
"為基底的結構會出現不正常的行為。"
935
929
936
930
#: ../../faq/design.rst:534
937
- #, fuzzy
938
931
msgid ""
939
932
"In the case of :class:`!ListWrapper`, whenever the wrapper object is in a "
940
933
"dictionary the wrapped list must not change to avoid anomalies. Don't do "
941
934
"this unless you are prepared to think hard about the requirements and the "
942
935
"consequences of not meeting them correctly. Consider yourself warned."
943
936
msgstr ""
944
- "至於 ListWrapper,只要這個包裝過的物件在字典中,裡面的串列就不能改變以避免不 "
945
- "正常的事情發生 。除非你已經謹慎思考過你的需求和無法滿足條件的後果,不然請不要 "
946
- "這麼做 。請自行注意。"
937
+ "至於:class:`! ListWrapper` ,只要這個包裝過的物件在字典中,裡面的串列就不能改 "
938
+ "變以避免不正常的事情發生 。除非你已經謹慎思考過你的需求和無法滿足條件的後果,"
939
+ "不然請不要這麼做 。請自行注意。"
947
940
948
941
#: ../../faq/design.rst:541
949
942
msgid "Why doesn't list.sort() return the sorted list?"
@@ -1028,7 +1021,6 @@ msgstr ""
1028
1021
"用來建構詳盡徹底的測試套件來測試模組裡的每一行程式碼。"
1029
1022
1030
1023
#: ../../faq/design.rst:584
1031
- #, fuzzy
1032
1024
msgid ""
1033
1025
"An appropriate testing discipline can help build large complex applications "
1034
1026
"in Python as well as having interface specifications would. In fact, it can "
@@ -1041,9 +1033,9 @@ msgid ""
1041
1033
msgstr ""
1042
1034
"就像介面規範一樣,一個適當的測試規則在建造大型又複雜的 Python 應用程式時可以"
1043
1035
"幫上忙。事實上,他可能可以有更好的表現,因為介面規範無法測試程式的特定屬性。"
1044
- "舉例來說,:meth:`append` 方法應該要在某個內部的串列最後面加上新的元素,而介面 "
1045
- "規範沒辦法測試你的 :meth:`append` 是不是真的有正確的實作,但這在測試套件裡是 "
1046
- "件很簡單的事 。"
1036
+ "舉例來說,:meth:`list. append` 方法應該要在某個內部的串列最後面加上新的元素,"
1037
+ "而介面規範沒辦法測試你的 :meth:`list. append` 是不是真的有正確的實作,但這在測 "
1038
+ "試套件裡是件很簡單的事 。"
1047
1039
1048
1040
#: ../../faq/design.rst:592
1049
1041
msgid ""
@@ -1062,7 +1054,6 @@ msgid "Why is there no goto?"
1062
1054
msgstr "為何沒有 goto 語法?"
1063
1055
1064
1056
#: ../../faq/design.rst:602
1065
- #, fuzzy
1066
1057
msgid ""
1067
1058
"In the 1970s people realized that unrestricted goto could lead to messy "
1068
1059
"\" spaghetti\" code that was hard to understand and revise. In a high-level "
@@ -1074,30 +1065,30 @@ msgid ""
1074
1065
msgstr ""
1075
1066
"在 1970 年代,人們了解到沒有限制的 goto 會導致混亂、難以理解和修改的「義大利"
1076
1067
"麵」程式碼 (\" spaghetti\" code)。在高階語言裡,這也是不需要的,因為有方法可以"
1077
- "做邏輯分支(以 Python 來說,用 ``if`` 陳述式和 ``or``、``and`` 及 ``if-"
1078
- "else`` 運算式)和迴圈(用 ``while`` 和 ``for`` 陳述式,可能會有 ``continue`` "
1079
- "和 ``break``)。"
1068
+ "做邏輯分支(以 Python 來說,用 :keyword:`if` 陳述式和 :keyword:`or`、:"
1069
+ "keyword:`and` 及 :keyword:`if`/:keyword:`else` 運算式)和迴圈(用 :keyword:"
1070
+ "`while` 和 :keyword:`for` 陳述式,可能會有 :keyword:`continue` 和 :keyword:"
1071
+ "`break`)。"
1080
1072
1081
1073
#: ../../faq/design.rst:609
1082
- #, fuzzy
1083
1074
msgid ""
1084
1075
"One can also use exceptions to provide a\" structured goto\" that works even "
1085
1076
"across function calls. Many feel that exceptions can conveniently emulate "
1086
1077
"all reasonable uses of the ``go`` or ``goto`` constructs of C, Fortran, and "
1087
1078
"other languages. For example::"
1088
1079
msgstr ""
1089
1080
"我們也可以用例外來做「結構化的 goto」,這甚至可以跨函式呼叫。很多人覺得例外可"
1090
- "以方便地模擬在 C、Fortran 和其他語言裡各種合理使用的「go」和「 goto」 。例"
1081
+ "以方便地模擬在 C、Fortran 和其他語言裡各種合理使用的 ``go`` 和 `` goto`` 。例"
1091
1082
"如:\n"
1092
1083
"\n"
1093
1084
"::"
1094
1085
1095
1086
#: ../../faq/design.rst:625
1096
- #, fuzzy
1097
1087
msgid ""
1098
1088
"This doesn't allow you to jump into the middle of a loop, but that's usually "
1099
1089
"considered an abuse of ``goto`` anyway. Use sparingly."
1100
- msgstr "這依然不能讓你跳進迴圈內,這通常被認為是對 goto 的濫用。請小心使用。"
1090
+ msgstr ""
1091
+ "這依然不能讓你跳進迴圈內,這通常被認為是對 ``goto`` 的濫用。請小心使用。"
1101
1092
1102
1093
#: ../../faq/design.rst:630
1103
1094
msgid "Why can't raw strings (r-strings) end with a backslash?"
@@ -1148,14 +1139,13 @@ msgid "Why doesn't Python have a \"with\" statement for attribute assignments?"
1148
1139
msgstr "為何 Python 沒有屬性賦值的 with 陳述式?"
1149
1140
1150
1141
#: ../../faq/design.rst:658
1151
- #, fuzzy
1152
1142
msgid ""
1153
1143
"Python has a :keyword:`with` statement that wraps the execution of a block, "
1154
1144
"calling code on the entrance and exit from the block. Some languages have a "
1155
1145
"construct that looks like this::"
1156
1146
msgstr ""
1157
- "Python 的 with 陳述式包裝了一區塊程式的執行,在進入和離開該區塊時執行程式碼。 "
1158
- "一些語言會有像如下的結構:\n"
1147
+ "Python 的:keyword:` with` 陳述式包裝了一區塊程式的執行,在進入和離開該區塊時 "
1148
+ "執行程式碼。 一些語言會有像如下的結構:\n"
1159
1149
"\n"
1160
1150
"::"
1161
1151
@@ -1194,28 +1184,26 @@ msgstr ""
1194
1184
"::"
1195
1185
1196
1186
#: ../../faq/design.rst:685
1197
- #, fuzzy
1198
1187
msgid ""
1199
1188
"The snippet assumes that ``a`` must have a member attribute called ``x``. "
1200
1189
"However, there is nothing in Python that tells the interpreter this. What "
1201
1190
"should happen if ``a`` is, let us say, an integer? If there is a global "
1202
1191
"variable named ``x``, will it be used inside the :keyword:`with` block? As "
1203
1192
"you see, the dynamic nature of Python makes such choices much harder."
1204
1193
msgstr ""
1205
- "這段程式碼假設「a」 有一個叫做「x」 的成員屬性。然後,Python裡並沒有任何跡象告 "
1206
- "訴直譯器這件事 。在假設「a」是一個整數的話,那會發生什麼事?如果有一個全域變數 "
1207
- "稱為「x」 ,那在這個 with 區塊會被使用嗎?如你所見,Python動態的天性使得這種 "
1208
- "選擇更加困難 。"
1194
+ "這段程式碼假設 ``a`` 有一個叫做 ``x`` 的成員屬性。然後,Python裡並沒有任何跡 "
1195
+ "象告訴直譯器這件事 。在假設「a」是一個整數的話,那會發生什麼事?如果有一個全域 "
1196
+ "變數稱為 ``x`` ,那在這個:keyword:` with` 區塊會被使用嗎?如你所見,Python動 "
1197
+ "態的天性使得這種選擇更加困難 。"
1209
1198
1210
1199
#: ../../faq/design.rst:691
1211
- #, fuzzy
1212
1200
msgid ""
1213
1201
"The primary benefit of :keyword:`with` and similar language features "
1214
1202
"(reduction of code volume) can, however, easily be achieved in Python by "
1215
1203
"assignment. Instead of::"
1216
1204
msgstr ""
1217
- "然而, with 陳述式或類似的語言特性(減少程式碼量)的主要好處可以透過賦值來達 "
1218
- "成 。相較於這樣寫:\n"
1205
+ "然而 :keyword:` with` 陳述式或類似的語言特性(減少程式碼量)的主要好處可以透過 "
1206
+ "賦值來達成 。相較於這樣寫:\n"
1219
1207
"\n"
1220
1208
"::"
1221
1209
@@ -1247,7 +1235,6 @@ msgid "Why don't generators support the with statement?"
1247
1235
msgstr "為何產生器 (generator) 不支援 with 陳述式?"
1248
1236
1249
1237
#: ../../faq/design.rst:717
1250
- #, fuzzy
1251
1238
msgid ""
1252
1239
"For technical reasons, a generator used directly as a context manager would "
1253
1240
"not work correctly. When, as is most common, a generator is used as an "
@@ -1257,7 +1244,8 @@ msgid ""
1257
1244
msgstr ""
1258
1245
"出於技術原因,把產生器直接用作情境 (context) 管理器會無法正常運作。因為通常來"
1259
1246
"說,產生器是被當成疊代器 (iterator),到最後完成時不需要被手動關閉。但如果你需"
1260
- "要的話,你可以在 with 陳述式裡用「contextlib.closing(generator)」來包裝他。"
1247
+ "要的話,你可以在 :keyword:`with` 陳述式裡用 :func:`contextlib."
1248
+ "closing(generator) <contextlib.closing>` 來包裝他。"
1261
1249
1262
1250
#: ../../faq/design.rst:725
1263
1251
msgid "Why are colons required for the if/while/def/class statements?"