@@ -1129,18 +1129,22 @@ msgstr ""
1129
1129
1130
1130
#: ../../faq/design.rst:653
1131
1131
msgid "Why doesn't Python have a \" with\" statement for attribute assignments?"
1132
- msgstr ""
1132
+ msgstr "為何 Python 沒有屬性賦值的 with 陳述式? "
1133
1133
1134
1134
#: ../../faq/design.rst:655
1135
1135
msgid ""
1136
1136
"Python has a 'with' statement that wraps the execution of a block, calling "
1137
1137
"code on the entrance and exit from the block. Some languages have a "
1138
1138
"construct that looks like this::"
1139
1139
msgstr ""
1140
+ "Python 的 with 陳述式包裝了一區塊程式的執行,在進入和離開該區塊時執行程式碼。"
1141
+ "一些語言會有像如下的結構:\n"
1142
+ "\n"
1143
+ "::"
1140
1144
1141
1145
#: ../../faq/design.rst:663
1142
1146
msgid "In Python, such a construct would be ambiguous."
1143
- msgstr ""
1147
+ msgstr "但在 Python,這種結構是模糊的。 "
1144
1148
1145
1149
#: ../../faq/design.rst:665
1146
1150
msgid ""
@@ -1149,6 +1153,9 @@ msgid ""
1149
1153
"assigned to. This is the main point of static typing -- the compiler "
1150
1154
"*always* knows the scope of every variable at compile time."
1151
1155
msgstr ""
1156
+ "在其他語言裡,像是 Object Pascal、Delphi 和 C++,使用的是靜態型別,所以我們可"
1157
+ "以清楚地知道是哪一個成員被指派值。這是靜態型別的重點 — 在編譯的時候,編譯器永"
1158
+ "遠都知道每個變數的範圍 (scope)。"
1152
1159
1153
1160
#: ../../faq/design.rst:670
1154
1161
msgid ""
@@ -1158,10 +1165,16 @@ msgid ""
1158
1165
"simple reading, what attribute is being referenced: a local one, a global "
1159
1166
"one, or a member attribute?"
1160
1167
msgstr ""
1168
+ "Python 使用的是動態型別。所以我們不可能提前知道在執行時哪個屬性會被使用到。成"
1169
+ "員屬性可能在執行時從物件中被新增或移除。這使得如果簡單來看的話,我們無法得知"
1170
+ "以下哪個屬性會被使用:區域的、全域的、或是成員屬性?"
1161
1171
1162
1172
#: ../../faq/design.rst:676
1163
1173
msgid "For instance, take the following incomplete snippet::"
1164
1174
msgstr ""
1175
+ "以下列不完整的程式碼為例:\n"
1176
+ "\n"
1177
+ "::"
1165
1178
1166
1179
#: ../../faq/design.rst:682
1167
1180
msgid ""
@@ -1171,24 +1184,37 @@ msgid ""
1171
1184
"variable named \" x\" , will it be used inside the with block? As you see, "
1172
1185
"the dynamic nature of Python makes such choices much harder."
1173
1186
msgstr ""
1187
+ "這段程式碼假設「a」有一個叫做「x」的成員屬性。然後,Python 裡並沒有任何跡象告"
1188
+ "訴直譯器這件事。在假設「a」是一個整數的話,那會發生什麼事?如果有一個全域變數"
1189
+ "稱為「x」,那在這個 with 區塊會被使用嗎?如你所見,Python 動態的天性使得這種"
1190
+ "選擇更加困難。"
1174
1191
1175
1192
#: ../../faq/design.rst:688
1176
1193
msgid ""
1177
1194
"The primary benefit of \" with\" and similar language features (reduction of "
1178
1195
"code volume) can, however, easily be achieved in Python by assignment. "
1179
1196
"Instead of::"
1180
1197
msgstr ""
1198
+ "然而,with 陳述式或類似的語言特性(減少程式碼量)的主要好處可以透過賦值來達"
1199
+ "成,而非如下:\n"
1200
+ "\n"
1201
+ "::"
1181
1202
1182
1203
#: ../../faq/design.rst:695
1183
1204
msgid "write this::"
1184
1205
msgstr ""
1206
+ "應該寫成這樣:\n"
1207
+ "\n"
1208
+ "::"
1185
1209
1186
1210
#: ../../faq/design.rst:702
1187
1211
msgid ""
1188
1212
"This also has the side-effect of increasing execution speed because name "
1189
1213
"bindings are resolved at run-time in Python, and the second version only "
1190
1214
"needs to perform the resolution once."
1191
1215
msgstr ""
1216
+ "這也有提升執行速度的副作用,因為 Python 的名稱綁定解析會在執行的時候發生,而"
1217
+ "第二版只需要執行解析一次即可。"
1192
1218
1193
1219
#: ../../faq/design.rst:708
1194
1220
msgid "Why don't generators support the with statement?"
0 commit comments