@@ -7,7 +7,7 @@ msgstr ""
7
7
"Project-Id-Version :Python 3.13\n "
8
8
"Report-Msgid-Bugs-To :\n "
9
9
"POT-Creation-Date :2024-09-03 11:11+0800\n "
10
- "PO-Revision-Date :2018-05-23 16:17+0000 \n "
10
+ "PO-Revision-Date :2024-10-03 11:47+0800 \n "
11
11
"Last-Translator :Adrian Liaw <adrianliaw2000@gmail.com>\n "
12
12
"Language-Team :Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
13
13
"tw)\n "
@@ -16,6 +16,7 @@ msgstr ""
16
16
"Content-Type :text/plain; charset=UTF-8\n "
17
17
"Content-Transfer-Encoding :8bit\n "
18
18
"Plural-Forms :nplurals=1; plural=0;\n "
19
+ "X-Generator :Poedit 3.5\n "
19
20
20
21
#: ../../reference/import.rst:6
21
22
msgid "The import system"
@@ -29,6 +30,10 @@ msgid ""
29
30
"way. Functions such as :func:`importlib.import_module` and built-in :func:"
30
31
"`__import__` can also be used to invoke the import machinery."
31
32
msgstr ""
33
+ "一個 :term:`module` 中的 Python 程式碼通過 :term:`importing` 的過程來存取另一"
34
+ "個模組中的程式碼。:keyword:`import` 陳述式是調用 (invoke) 引入機制最常見的方"
35
+ "法,但這不是唯一的方法。函式如 :func:`importlib.import_module` 以及內建函式 :"
36
+ "func:`__import__` 也可以用來調用引入機制。"
32
37
33
38
#: ../../reference/import.rst:16
34
39
msgid ""
@@ -41,6 +46,11 @@ msgid ""
41
46
"keyword:`!import` statement for the exact details of that name binding "
42
47
"operation."
43
48
msgstr ""
49
+ ":keyword:`import` 陳述式結合了兩個操作:首先搜尋指定的模組,然後將搜尋結果繫"
50
+ "結到本地作用域中的一個名稱。:keyword:`!import` 陳述式的搜索操作被定義為一個"
51
+ "對 :func:`__import__` 函式的呼叫,並帶有相應的引數。:func:`__import__` 的回傳"
52
+ "值用於執行 :keyword:`!import` 陳述式的名稱繫結操作。有關名稱繫結操作的詳細資"
53
+ "訊,請參見 :keyword:`!import` 陳述式。"
44
54
45
55
#: ../../reference/import.rst:25
46
56
msgid ""
@@ -50,6 +60,10 @@ msgid ""
50
60
"(including :data:`sys.modules`), only the :keyword:`import` statement "
51
61
"performs a name binding operation."
52
62
msgstr ""
63
+ "直接呼叫 :func:`__import__` 只會執行模組搜尋操作,以及在找到時執行模組的建立"
64
+ "操作。雖然某些副作用可能會發生,例如引入父套件 (parent package),以及更新各種"
65
+ "快取(包括 :data:`sys.modules`),但只有 :keyword:`import` 陳述式會執行名稱繫"
66
+ "結操作。"
53
67
54
68
#: ../../reference/import.rst:31
55
69
msgid ""
@@ -58,6 +72,9 @@ msgid ""
58
72
"system (such as :func:`importlib.import_module`) may choose to bypass :func:"
59
73
"`__import__` and use their own solutions to implement import semantics."
60
74
msgstr ""
75
+ "當執行 :keyword:`import` 陳述式時,會呼叫內建的 :func:`__import__` 函式。其他"
76
+ "調用引入系統的機制(如 :func:`importlib.import_module`)可以選擇略過 :func:"
77
+ "`__import__`,並使用它們自己的解決方案來實作引入語意。"
61
78
62
79
#: ../../reference/import.rst:36
63
80
msgid ""
@@ -68,6 +85,10 @@ msgid ""
68
85
"machinery is invoked. These strategies can be modified and extended by "
69
86
"using various hooks described in the sections below."
70
87
msgstr ""
88
+ "當模組首次被引入時,Python 會搜尋該模組,若找到則會建立一個模組物件 "
89
+ "[#fnmo]_,並對其進行初始化。如果找不到指定的模組,則會引發 :exc:"
90
+ "`ModuleNotFoundError`。當引入機制被調用時,Python 會實作各種策略來搜尋指定的"
91
+ "模組。這些策略可以透過使用以下章節描述的各種 hook(掛鉤)來修改和擴展。"
71
92
72
93
#: ../../reference/import.rst:43
73
94
msgid ""
@@ -76,6 +97,9 @@ msgid ""
76
97
"import system is exposed through :data:`sys.meta_path`. In addition, native "
77
98
"namespace package support has been implemented (see :pep:`420`)."
78
99
msgstr ""
100
+ "引入系統已被更新,以完全實作 :pep:`302` 的第二階段。不再有隱式引入機制——完整"
101
+ "的引入系統已透過 :data:`sys.meta_path` 公開。此外,原生命名空間套件支援(請參"
102
+ "閱 :pep:`420`)也已被實作。"
79
103
80
104
#: ../../reference/import.rst:51
81
105
msgid ":mod:`importlib`"
@@ -89,6 +113,9 @@ msgid ""
89
113
"import machinery. Refer to the :mod:`importlib` library documentation for "
90
114
"additional detail."
91
115
msgstr ""
116
+ ":mod:`importlib` 模組提供了豐富的 API 來與引入系統互動。例如,:func:"
117
+ "`importlib.import_module` 提供了一個比內建的 :func:`__import__` 更推薦且更簡"
118
+ "單的 API 來調用引入機制。更多詳細資訊請參閱 :mod:`importlib` 函式庫文件。"
92
119
93
120
#: ../../reference/import.rst:62
94
121
msgid "Packages"
@@ -101,6 +128,9 @@ msgid ""
101
128
"else. To help organize modules and provide a naming hierarchy, Python has a "
102
129
"concept of :term:`packages <package>`."
103
130
msgstr ""
131
+ "Python 只有一種類型的模組物件,且所有模組,無論其是使用 Python、C 還是其他語"
132
+ "言實作,都是這種類型。為了幫助組織模組並提供命名階層,Python 導入了 :term:`套"
133
+ "件 <package>` 的概念。"
104
134
105
135
#: ../../reference/import.rst:72
106
136
msgid ""
@@ -112,6 +142,10 @@ msgid ""
112
142
"hierarchically, and packages may themselves contain subpackages, as well as "
113
143
"regular modules."
114
144
msgstr ""
145
+ "你可以將套件視為檔案系統中的目錄,模組則是目錄中的檔案,但不要過於字面地理解"
146
+ "這個比喻,因為套件和模組不一定來自檔案系統。為了方便解釋,我們將使用這個目錄"
147
+ "和檔案的比喻。就像檔案系統目錄一樣,套件是分層組織的,套件本身可以包含子套件"
148
+ "以及一般模組。"
115
149
116
150
#: ../../reference/import.rst:80
117
151
msgid ""
@@ -120,6 +154,8 @@ msgid ""
120
154
"of module. Specifically, any module that contains a ``__path__`` attribute "
121
155
"is considered a package."
122
156
msgstr ""
157
+ "請記住,所有的套件都是模組,但並非所有模組都是套件。換句話說,套件只是一種特"
158
+ "殊的模組。具體來說,任何包含 ``__path__`` 屬性的模組都被視為套件。"
123
159
124
160
#: ../../reference/import.rst:85
125
161
msgid ""
@@ -129,10 +165,14 @@ msgid ""
129
165
"subpackage called :mod:`email.mime` and a module within that subpackage "
130
166
"called :mod:`email.mime.text`."
131
167
msgstr ""
168
+ "所有模組都有一個名稱。子套件的名稱與其父套件名稱之間用一個點來分隔,類似於 "
169
+ "Python 的標準屬性存取語法。因此,你可能會有一個名為 :mod:`email` 的套件,該套"
170
+ "件又有一個名為 :mod:`email.mime` 的子套件,並且該子套件中有一個名為 :mod:"
171
+ "`email.mime.text` 的模組。"
132
172
133
173
#: ../../reference/import.rst:93
134
174
msgid "Regular packages"
135
- msgstr ""
175
+ msgstr "一般套件 "
136
176
137
177
#: ../../reference/import.rst:98
138
178
msgid ""
@@ -146,12 +186,20 @@ msgid ""
146
186
"same Python code that any other module can contain, and Python will add some "
147
187
"additional attributes to the module when it is imported."
148
188
msgstr ""
189
+ "Python 定義了兩種類型的套件,:term:`一般套件 <regular package>`\\ 和\\ :term:"
190
+ "`命名空間套件 <namespace package>`。一般套件是 Python 3.2 及更早版本中存在的"
191
+ "傳統套件。一般套件通常實作成一個包含 ``__init__.py`` 檔案的目錄。當引入一般套"
192
+ "件時,該 ``__init__.py`` 檔案會被隱式執行,其定義的物件會繫結到該套件的命名空"
193
+ "間中的名稱。``__init__.py`` 檔案可以包含與任何其他模組相同的 Python 代碼,並"
194
+ "且 Python 會在引入時為該模組增加一些額外的屬性。"
149
195
150
196
#: ../../reference/import.rst:108
151
197
msgid ""
152
198
"For example, the following file system layout defines a top level ``parent`` "
153
199
"package with three subpackages::"
154
200
msgstr ""
201
+ "例如,以下檔案系統布置定義了一個頂層的 ``parent`` 套件,該套件包含三個子套"
202
+ "件: ::"
155
203
156
204
#: ../../reference/import.rst:111
157
205
msgid ""
@@ -180,10 +228,13 @@ msgid ""
180
228
"``parent.three`` will execute ``parent/two/__init__.py`` and ``parent/three/"
181
229
"__init__.py`` respectively."
182
230
msgstr ""
231
+ "引入 ``parent.one`` 將隱式執行 ``parent/__init__.py`` 和 ``parent/one/"
232
+ "__init__.py``。隨後引入 ``parent.two`` 或 ``parent.three`` 將分別執行 "
233
+ "``parent/two/__init__.py`` 和 ``parent/three/__init__.py``。"
183
234
184
235
#: ../../reference/import.rst:127
185
236
msgid "Namespace packages"
186
- msgstr ""
237
+ msgstr "命名空間套件 "
187
238
188
239
#: ../../reference/import.rst:133
189
240
msgid ""
@@ -195,6 +246,10 @@ msgid ""
195
246
"objects on the file system; they may be virtual modules that have no "
196
247
"concrete representation."
197
248
msgstr ""
249
+ "命名空間套件是由不同的\\ :term:`部分 <portion>` 組成的,每個部分都為父套件提"
250
+ "供一個子套件。這些部分可以位於檔案系統上的不同位置。部分可能也存在於壓縮檔案"
251
+ "中、網路上,或 Python 在引入時搜索的任何其他地方。命名空間套件不一定直接對應"
252
+ "於檔案系統中的對象;它們可能是沒有具體表示的虛擬模組。"
198
253
199
254
#: ../../reference/import.rst:141
200
255
msgid ""
@@ -204,6 +259,9 @@ msgid ""
204
259
"that package if the path of their parent package (or :data:`sys.path` for a "
205
260
"top level package) changes."
206
261
msgstr ""
262
+ "命名空間套件的 ``__path__`` 屬性不使用普通的串列。它們使用自定義的可疊代型"
263
+ "別,當父套件的路徑(或頂層套件的 :data:`sys.path`)發生變化時,會在下一次引入"
264
+ "嘗試時自動執行新一輪的套件部分搜索。"
207
265
208
266
#: ../../reference/import.rst:147
209
267
msgid ""
@@ -214,10 +272,15 @@ msgid ""
214
272
"create a namespace package for the top-level ``parent`` package whenever it "
215
273
"or one of its subpackages is imported."
216
274
msgstr ""
275
+ "在命名空間套件中,不存在 ``parent/__init__.py`` 檔案。實際上,在引入搜索過程"
276
+ "中可能會找到多個 ``parent`` 目錄,每個目錄由不同的部分提供。因此,``parent/"
277
+ "one`` 可能與 ``parent/two`` 不會實際位於一起。在這種情況下,每當引入頂層 "
278
+ "``parent`` 套件或其子套件之一時,Python 會為頂層 ``parent`` 套件建立一個命名"
279
+ "空間套件。"
217
280
218
281
#: ../../reference/import.rst:154
219
282
msgid "See also :pep:`420` for the namespace package specification."
220
- msgstr ""
283
+ msgstr "有關命名空間套件的規範,請參見 :pep:`420`。 "
221
284
222
285
#: ../../reference/import.rst:158
223
286
msgid "Searching"