@@ -1184,6 +1184,9 @@ msgid ""
1184
1184
"unified interface for retrieving the data necessary for pickling and copying "
1185
1185
"objects. [#]_"
1186
1186
msgstr ""
1187
+ "如稍後所演示,pickle 並不直接使用上述方法。這些方法實際上是實作了 :meth:"
1188
+ "`~object.__reduce__` 特殊方法的拷貝協定(copy protocol)。拷貝協定提供了統一"
1189
+ "的介面,以檢索進行封裝及複製物件時所需的資料。 [#]_"
1187
1190
1188
1191
#: ../../library/pickle.rst:672
1189
1192
msgid ""
@@ -1194,13 +1197,20 @@ msgid ""
1194
1197
"We will show, however, cases where using :meth:`!__reduce__` is the only "
1195
1198
"option or leads to more efficient pickling or both."
1196
1199
msgstr ""
1200
+ "直接在類別中實作 :meth:`~object.__reduce__` 雖然功能強大但卻容易導致出錯。因"
1201
+ "此,設計類別者應盡可能使用高階介面(例如,:meth:`~object."
1202
+ "__getnewargs_ex__`、:meth:`~object.__getstate__` 和 :meth:`~object."
1203
+ "__setstate__`)。不過,我們也將展示一些特例狀況,在這些狀況中,使用 :meth:`!"
1204
+ "__reduce__` 可能是唯一的選擇、是更有效率的封裝方法或二者兼備。"
1197
1205
1198
1206
#: ../../library/pickle.rst:681
1199
1207
msgid ""
1200
1208
"The interface is currently defined as follows. The :meth:`__reduce__` "
1201
1209
"method takes no argument and shall return either a string or preferably a "
1202
1210
"tuple (the returned object is often referred to as the \" reduce value\" )."
1203
1211
msgstr ""
1212
+ "目前的介面定義如下。 :meth:`__reduce__` 方法不接受引數,且應回傳一個字串或一"
1213
+ "個元組(元組一般而言是較佳的選擇;所回傳的物件通常稱為「縮減值」)。"
1204
1214
1205
1215
#: ../../library/pickle.rst:685
1206
1216
msgid ""
@@ -1209,25 +1219,32 @@ msgid ""
1209
1219
"module; the pickle module searches the module namespace to determine the "
1210
1220
"object's module. This behaviour is typically useful for singletons."
1211
1221
msgstr ""
1222
+ "如果回傳的是字串,該字串應被解讀為一個全域變數的名稱。它應是該物件相對其所在"
1223
+ "模組的本地名稱;pickle 模組會在模組命名空間中尋找,以確定該物件所在的模組。這"
1224
+ "種行為通常對於單例物件特別有用。"
1212
1225
1213
1226
#: ../../library/pickle.rst:690
1214
1227
msgid ""
1215
1228
"When a tuple is returned, it must be between two and six items long. "
1216
1229
"Optional items can either be omitted, or ``None`` can be provided as their "
1217
1230
"value. The semantics of each item are in order:"
1218
1231
msgstr ""
1232
+ "當返回一個元組時,其長度必須介於兩至六項元素之間。可選項可以被省略,或者其值"
1233
+ "可以被設為 ``None``。各項物件的語意依序為:"
1219
1234
1220
1235
#: ../../library/pickle.rst:696
1221
1236
msgid ""
1222
1237
"A callable object that will be called to create the initial version of the "
1223
1238
"object."
1224
- msgstr ""
1239
+ msgstr "一個將會被呼叫來創建初始版本物件的可呼叫物件。 "
1225
1240
1226
1241
#: ../../library/pickle.rst:699
1227
1242
msgid ""
1228
1243
"A tuple of arguments for the callable object. An empty tuple must be given "
1229
1244
"if the callable does not accept any argument."
1230
1245
msgstr ""
1246
+ "一個用於傳遞引數給前述物件的元組。如果前述物件不接受引數輸入,則你仍應在這裡"
1247
+ "給定一個空元組。"
1231
1248
1232
1249
#: ../../library/pickle.rst:702
1233
1250
msgid ""
@@ -1236,6 +1253,9 @@ msgid ""
1236
1253
"method then, the value must be a dictionary and it will be added to the "
1237
1254
"object's :attr:`~object.__dict__` attribute."
1238
1255
msgstr ""
1256
+ "可選項。物件狀態。如前所述,會被傳遞給該物件的 :meth:`__setstate__` 方法。如"
1257
+ "果該物件沒有實作此方法,則本值必須是一個字典,且其將會被新增到物件的 :attr:"
1258
+ "`~object.__dict__` 屬性中。"
1239
1259
1240
1260
#: ../../library/pickle.rst:707
1241
1261
msgid ""
@@ -1248,6 +1268,12 @@ msgid ""
1248
1268
"which pickle protocol version is used as well as the number of items to "
1249
1269
"append, so both must be supported.)"
1250
1270
msgstr ""
1271
+ "可選項。一個用來提供連續項目的疊代器(而非序列)。這些項目將個別透過 ``obj."
1272
+ "append(item)`` 方法或成批次地透過 ``obj.extend(list_of_items)`` 方法被附加到"
1273
+ "物件中。主要用於串列(list)子類別,但只要其他類別具有相應的 :ref:`append 和 "
1274
+ "extend 方法 <typesseq-common>`就也可以使用。 (如何選擇使用 :meth:`!append` "
1275
+ "或 :meth:`!extend` 方法將取決於所選用的 pickle 協定版本以及要附加的項目數量,"
1276
+ "因此必須同時支援這兩種方法。)"
1251
1277
1252
1278
#: ../../library/pickle.rst:717
1253
1279
msgid ""
@@ -1256,6 +1282,9 @@ msgid ""
1256
1282
"value``. This is primarily used for dictionary subclasses, but may be used "
1257
1283
"by other classes as long as they implement :meth:`__setitem__`."
1258
1284
msgstr ""
1285
+ "可選項。一個產生連續鍵值對的疊代器(不是序列)。這些項目將以 ``obj[key] = "
1286
+ "value`` 方式被儲存到物件中。主要用於字典(dictionary)子類別,但只要有實現"
1287
+ "了 :meth:`__setitem__` 的其他類別也可以使用。"
1259
1288
1260
1289
#: ../../library/pickle.rst:722
1261
1290
msgid ""
0 commit comments