@@ -57,19 +57,22 @@ msgid ""
57
57
"The\" primer\" gives a basic overview, moving gently from simple examples, "
58
58
"adding one feature at a time. Start here if you're new to descriptors."
59
59
msgstr ""
60
+ "「入門」提供基本概述,從簡單範例開始逐步介紹,一次新增一個功能。如果你是描述器的新手,請從這裡開始。"
60
61
61
62
#: ../../howto/descriptor.rst:21
62
63
msgid ""
63
64
"The second section shows a complete, practical descriptor example. If you "
64
65
"already know the basics, start there."
65
66
msgstr ""
67
+ "第二個章節展示完整、實用的描述器範例。如果你已經了解基礎知識,可以從那裡開始。"
66
68
67
69
#: ../../howto/descriptor.rst:24
68
70
msgid ""
69
71
"The third section provides a more technical tutorial that goes into the "
70
72
"detailed mechanics of how descriptors work. Most people don't need this "
71
73
"level of detail."
72
74
msgstr ""
75
+ "第三個章節提供更技術性的教學,深入探討描述器運作的詳細機制。大部分的人不需要這種程度的細節。"
73
76
74
77
#: ../../howto/descriptor.rst:28
75
78
msgid ""
@@ -79,26 +82,29 @@ msgid ""
79
82
"like :func:`classmethod`, :func:`staticmethod`, :func:`property`, "
80
83
"and :term:`__slots__`."
81
84
msgstr ""
85
+ "最後一個章節提供以 C 語言撰寫的內建描述器的純 Python 等價實作。如果你好奇函式如何轉變為綁定方法,或者想了解常見工具如 :func:`classmethod`、:func:`staticmethod`、:func:`property` 和 :term:`__slots__` 的實作方式,請閱讀此章節。"
82
86
83
87
#: ../../howto/descriptor.rst:36
84
88
msgid "Primer"
85
- msgstr ""
89
+ msgstr "入門 "
86
90
87
91
#: ../../howto/descriptor.rst:38
88
92
msgid ""
89
93
"In this primer, we start with the most basic possible example and then we'll "
90
94
"add new capabilities one by one."
91
95
msgstr ""
96
+ "在此入門教學中,我們從最基礎的範例開始,然後逐一新增新功能。"
92
97
93
98
#: ../../howto/descriptor.rst:43
94
99
msgid "Simple example: A descriptor that returns a constant"
95
- msgstr ""
100
+ msgstr "簡單範例:回傳常數的描述器 "
96
101
97
102
#: ../../howto/descriptor.rst:45
98
103
msgid ""
99
104
"The :class:`!Ten` class is a descriptor whose :meth:`~object.__get__` method "
100
105
"always returns the constant ``10``:"
101
106
msgstr ""
107
+ ":class:`!Ten` 類別是一個描述器,它的 :meth:`~object.__get__` 方法總是回傳常數 ``10``:"
102
108
103
109
#: ../../howto/descriptor.rst:48
104
110
msgid ""
@@ -115,6 +121,7 @@ msgid ""
115
121
"To use the descriptor, it must be stored as a class variable in another "
116
122
"class:"
117
123
msgstr ""
124
+ "要使用描述器,必須將它儲存為另一個類別的類別變數:"
118
125
119
126
#: ../../howto/descriptor.rst:56
120
127
msgid ""
@@ -128,6 +135,7 @@ msgid ""
128
135
"An interactive session shows the difference between normal attribute lookup "
129
136
"and descriptor lookup:"
130
137
msgstr ""
138
+ "互動式工作階段顯示一般屬性查找和描述器查找之間的差異:"
131
139
132
140
#: ../../howto/descriptor.rst:65
133
141
msgid ""
@@ -145,33 +153,38 @@ msgid ""
145
153
"descriptor instance, recognized by its ``__get__`` method. Calling that "
146
154
"method returns ``10``."
147
155
msgstr ""
156
+ "在 ``a.x`` 屬性查找中,點運算子在類別字典中找到 ``'x': 5``。在 ``a.y`` 查找中,點運算子找到一個描述器實例,透過其 ``__get__`` 方法來識別。呼叫該方法回傳 ``10``。"
148
157
149
158
#: ../../howto/descriptor.rst:78
150
159
msgid ""
151
160
"Note that the value ``10`` is not stored in either the class dictionary or "
152
161
"the instance dictionary. Instead, the value ``10`` is computed on demand."
153
162
msgstr ""
163
+ "請注意,數值 ``10`` 並不儲存在類別字典或實例字典中。相反地,數值 ``10`` 是按需計算的。"
154
164
155
165
#: ../../howto/descriptor.rst:81
156
166
msgid ""
157
167
"This example shows how a simple descriptor works, but it isn't very useful. "
158
168
"For retrieving constants, normal attribute lookup would be better."
159
169
msgstr ""
170
+ "這個範例顯示了簡單描述器的運作方式,但它並不是很有用。對於取得常數,一般的屬性查找會比較好。"
160
171
161
172
#: ../../howto/descriptor.rst:84
162
173
msgid ""
163
174
"In the next section, we'll create something more useful, a dynamic lookup."
164
175
msgstr ""
176
+ "在下一個章節中,我們將建立更有用的東西:動態查找。"
165
177
166
178
#: ../../howto/descriptor.rst:88
167
179
msgid "Dynamic lookups"
168
- msgstr ""
180
+ msgstr "動態查找 "
169
181
170
182
#: ../../howto/descriptor.rst:90
171
183
msgid ""
172
184
"Interesting descriptors typically run computations instead of returning "
173
185
"constants:"
174
186
msgstr ""
187
+ "有趣的描述器通常執行計算而不是回傳常數:"
175
188
176
189
#: ../../howto/descriptor.rst:93
177
190
msgid ""
@@ -195,6 +208,7 @@ msgid ""
195
208
"An interactive session shows that the lookup is dynamic — it computes "
196
209
"different, updated answers each time::"
197
210
msgstr ""
211
+ "互動式工作階段顯示查找是動態的——每次都會計算不同的更新答案: ::"
198
212
199
213
#: ../../howto/descriptor.rst:112
200
214
msgid ""
@@ -221,10 +235,11 @@ msgid ""
221
235
"parameter that lets the :meth:`~object.__get__` method learn the target "
222
236
"directory. The *objtype* parameter is the class *Directory*."
223
237
msgstr ""
238
+ "除了顯示描述器如何執行計算外,這個範例也揭示了 :meth:`~object.__get__` 參數的目的。*self* 參數是 *size*,一個 *DirectorySize* 的實例。*obj* 參數是 *g* 或 *s*,一個 *Directory* 的實例。正是 *obj* 參數讓 :meth:`~object.__get__` 方法得知目標目錄。*objtype* 參數是類別 *Directory*。"
224
239
225
240
#: ../../howto/descriptor.rst:131
226
241
msgid "Managed attributes"
227
- msgstr ""
242
+ msgstr "受管理的屬性 "
228
243
229
244
#: ../../howto/descriptor.rst:133
230
245
msgid ""
@@ -235,13 +250,15 @@ msgid ""
235
250
"and :meth:`~object.__set__` methods are triggered when the public attribute "
236
251
"is accessed."
237
252
msgstr ""
253
+ "描述器的一個常見用途是管理對實例資料的存取。描述器被指派給類別字典中的公開屬性,而實際資料則儲存為實例字典中的私有屬性。當存取公開屬性時,會觸發描述器的 :meth:`~object.__get__` 和 :meth:`~object.__set__` 方法。"
238
254
239
255
#: ../../howto/descriptor.rst:139
240
256
msgid ""
241
257
"In the following example, *age* is the public attribute and *_age* is the "
242
258
"private attribute. When the public attribute is accessed, the descriptor "
243
259
"logs the lookup or update:"
244
260
msgstr ""
261
+ "在以下範例中,*age* 是公開屬性,*_age* 是私有屬性。當存取公開屬性時,描述器會記錄查找或更新:"
245
262
246
263
#: ../../howto/descriptor.rst:143
247
264
msgid ""
@@ -318,13 +335,14 @@ msgstr ""
318
335
319
336
#: ../../howto/descriptor.rst:213
320
337
msgid "Customized names"
321
- msgstr ""
338
+ msgstr "自訂名稱 "
322
339
323
340
#: ../../howto/descriptor.rst:215
324
341
msgid ""
325
342
"When a class uses descriptors, it can inform each descriptor about which "
326
343
"variable name was used."
327
344
msgstr ""
345
+ "當類別使用描述器時,它可以告知每個描述器使用了哪個變數名稱。"
328
346
329
347
#: ../../howto/descriptor.rst:218
330
348
msgid ""
@@ -427,14 +445,15 @@ msgstr ""
427
445
428
446
#: ../../howto/descriptor.rst:295
429
447
msgid "Closing thoughts"
430
- msgstr ""
448
+ msgstr "結語 "
431
449
432
450
#: ../../howto/descriptor.rst:297
433
451
msgid ""
434
452
"A :term:`descriptor` is what we call any object that "
435
453
"defines :meth:`~object.__get__`, :meth:`~object.__set__`, "
436
454
"or :meth:`~object.__delete__`."
437
455
msgstr ""
456
+ ":term:`描述器 <descriptor>` 是我們對任何定義了 :meth:`~object.__get__`、:meth:`~object.__set__` 或 :meth:`~object.__delete__` 的物件的稱呼。"
438
457
439
458
#: ../../howto/descriptor.rst:300
440
459
msgid ""