Skip to content
  • Sponsor python/python-docs-zh-tw

  • Notifications You must be signed in to change notification settings
  • Fork 216
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1707687

Browse files
authoredOct 7, 2024··
Translate reference/import.po (#983)
* feat: to rst:241 feat: to rst:241 * fix: to rst: 336 * fix: Apply suggestions from code review
1 parent 7cf33e8 commit 1707687

File tree

1 file changed

+155
-11
lines changed

1 file changed

+155
-11
lines changed
 

‎reference/import.po

Lines changed: 155 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: Python 3.13\n"
88
"Report-Msgid-Bugs-To: \n"
9-
"POT-Creation-Date: 2024-09-28 00:13+0000\n"
10-
"PO-Revision-Date: 2018-05-23 16:17+0000\n"
9+
"POT-Creation-Date: 2024-09-03 11:11+0800\n"
10+
"PO-Revision-Date: 2024-10-07 21:14+0800\n"
1111
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
1212
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1313
"tw)\n"
@@ -16,6 +16,7 @@ msgstr ""
1616
"Content-Type: text/plain; charset=UTF-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
1818
"Plural-Forms: nplurals=1; plural=0;\n"
19+
"X-Generator: Poedit 3.5\n"
1920

2021
#: ../../reference/import.rst:6
2122
msgid "The import system"
@@ -29,6 +30,10 @@ msgid ""
2930
"way. Functions such as :func:`importlib.import_module` and built-in :func:"
3031
"`__import__` can also be used to invoke the import machinery."
3132
msgstr ""
33+
"一個 :term:`module` 中的 Python 程式碼透過 :term:`importing` 的過程來存取另一"
34+
"個模組中的程式碼。:keyword:`import` 陳述式是調用 (invoke) 引入機制最常見的方"
35+
"法,但這不是唯一的方法。函式如 :func:`importlib.import_module` 以及內建函式 :"
36+
"func:`__import__` 也可以用來調用引入機制。"
3237

3338
#: ../../reference/import.rst:16
3439
msgid ""
@@ -41,6 +46,11 @@ msgid ""
4146
"keyword:`!import` statement for the exact details of that name binding "
4247
"operation."
4348
msgstr ""
49+
":keyword:`import` 陳述式結合了兩個操作:首先搜尋指定的模組,然後將搜尋結果繫"
50+
"結到本地作用域中的一個名稱。:keyword:`!import` 陳述式的搜尋操作被定義為一個"
51+
"對 :func:`__import__` 函式的呼叫,並帶有相應的引數。:func:`__import__` 的回傳"
52+
"值用於執行 :keyword:`!import` 陳述式的名稱繫結操作。有關名稱繫結操作的詳細資"
53+
"訊,請參見 :keyword:`!import` 陳述式。"
4454

4555
#: ../../reference/import.rst:25
4656
msgid ""
@@ -50,6 +60,10 @@ msgid ""
5060
"(including :data:`sys.modules`), only the :keyword:`import` statement "
5161
"performs a name binding operation."
5262
msgstr ""
63+
"直接呼叫 :func:`__import__` 只會執行模組搜尋操作,以及在找到時執行模組的建立"
64+
"操作。雖然某些副作用可能會發生,例如引入父套件 (parent package),以及更新各種"
65+
"快取(包括 :data:`sys.modules`),但只有 :keyword:`import` 陳述式會執行名稱繫"
66+
"結操作。"
5367

5468
#: ../../reference/import.rst:31
5569
msgid ""
@@ -58,6 +72,9 @@ msgid ""
5872
"system (such as :func:`importlib.import_module`) may choose to bypass :func:"
5973
"`__import__` and use their own solutions to implement import semantics."
6074
msgstr ""
75+
"當執行 :keyword:`import` 陳述式時,會呼叫內建的 :func:`__import__` 函式。其他"
76+
"調用引入系統的機制(如 :func:`importlib.import_module`)可以選擇略過 :func:"
77+
"`__import__`,並使用它們自己的解決方案來實作引入語意。"
6178

6279
#: ../../reference/import.rst:36
6380
msgid ""
@@ -68,6 +85,10 @@ msgid ""
6885
"machinery is invoked. These strategies can be modified and extended by "
6986
"using various hooks described in the sections below."
7087
msgstr ""
88+
"當模組首次被引入時,Python 會搜尋該模組,若找到則會建立一個模組物件 "
89+
"[#fnmo]_,並對其進行初始化。如果找不到指定的模組,則會引發 :exc:"
90+
"`ModuleNotFoundError`。當引入機制被調用時,Python 會實作各種策略來搜尋指定的"
91+
"模組。這些策略可以透過使用以下章節描述的各種 hook(掛鉤)來修改和擴展。"
7192

7293
#: ../../reference/import.rst:43
7394
msgid ""
@@ -76,6 +97,9 @@ msgid ""
7697
"import system is exposed through :data:`sys.meta_path`. In addition, native "
7798
"namespace package support has been implemented (see :pep:`420`)."
7899
msgstr ""
100+
"引入系統已被更新,以完全實作 :pep:`302` 的第二階段。不再有隱式引入機制——完整"
101+
"的引入系統已透過 :data:`sys.meta_path` 公開。此外,原生命名空間套件支援(請參"
102+
"閱 :pep:`420`)也已被實作。"
79103

80104
#: ../../reference/import.rst:51
81105
msgid ":mod:`importlib`"
@@ -89,6 +113,9 @@ msgid ""
89113
"import machinery. Refer to the :mod:`importlib` library documentation for "
90114
"additional detail."
91115
msgstr ""
116+
":mod:`importlib` 模組提供了豐富的 API 來與引入系統互動。例如,:func:"
117+
"`importlib.import_module` 提供了一個比內建的 :func:`__import__` 更推薦且更簡"
118+
"單的 API 來調用引入機制。更多詳細資訊請參閱 :mod:`importlib` 函式庫文件。"
92119

93120
#: ../../reference/import.rst:62
94121
msgid "Packages"
@@ -101,6 +128,9 @@ msgid ""
101128
"else. To help organize modules and provide a naming hierarchy, Python has a "
102129
"concept of :term:`packages <package>`."
103130
msgstr ""
131+
"Python 只有一種類型的模組物件,且所有模組,無論其是使用 Python、C 還是其他語"
132+
"言實作,都是這種類型。為了幫助組織模組並提供命名階層,Python 導入了\\ :term:`"
133+
"套件 <package>`\\ 的概念。"
104134

105135
#: ../../reference/import.rst:72
106136
msgid ""
@@ -112,6 +142,10 @@ msgid ""
112142
"hierarchically, and packages may themselves contain subpackages, as well as "
113143
"regular modules."
114144
msgstr ""
145+
"你可以將套件視為檔案系統中的目錄,模組則是目錄中的檔案,但不要過於字面地理解"
146+
"這個比喻,因為套件和模組不一定來自檔案系統。為了方便解釋,我們將使用這個目錄"
147+
"和檔案的比喻。就像檔案系統目錄一樣,套件是分層組織的,套件本身可以包含子套件"
148+
"以及一般模組。"
115149

116150
#: ../../reference/import.rst:80
117151
msgid ""
@@ -120,6 +154,8 @@ msgid ""
120154
"of module. Specifically, any module that contains a ``__path__`` attribute "
121155
"is considered a package."
122156
msgstr ""
157+
"請記住,所有的套件都是模組,但並非所有模組都是套件。換句話說,套件只是一種特"
158+
"殊的模組。具體來說,任何包含 ``__path__`` 屬性的模組都被視為套件。"
123159

124160
#: ../../reference/import.rst:85
125161
msgid ""
@@ -129,10 +165,14 @@ msgid ""
129165
"subpackage called :mod:`email.mime` and a module within that subpackage "
130166
"called :mod:`email.mime.text`."
131167
msgstr ""
168+
"所有模組都有一個名稱。子套件的名稱與其父套件名稱之間用一個點來分隔,類似於 "
169+
"Python 的標準屬性存取語法。因此,你可能會有一個名為 :mod:`email` 的套件,該套"
170+
"件又有一個名為 :mod:`email.mime` 的子套件,並且該子套件中有一個名為 :mod:"
171+
"`email.mime.text` 的模組。"
132172

133173
#: ../../reference/import.rst:93
134174
msgid "Regular packages"
135-
msgstr ""
175+
msgstr "一般套件"
136176

137177
#: ../../reference/import.rst:98
138178
msgid ""
@@ -146,12 +186,20 @@ msgid ""
146186
"same Python code that any other module can contain, and Python will add some "
147187
"additional attributes to the module when it is imported."
148188
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 會在引入時為該模組增加一些額外的屬性。"
149195

150196
#: ../../reference/import.rst:108
151197
msgid ""
152198
"For example, the following file system layout defines a top level ``parent`` "
153199
"package with three subpackages::"
154200
msgstr ""
201+
"例如,以下檔案系統布置定義了一個頂層的 ``parent`` 套件,該套件包含三個子套"
202+
"件: ::"
155203

156204
#: ../../reference/import.rst:111
157205
msgid ""
@@ -180,10 +228,13 @@ msgid ""
180228
"``parent.three`` will execute ``parent/two/__init__.py`` and ``parent/three/"
181229
"__init__.py`` respectively."
182230
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``。"
183234

184235
#: ../../reference/import.rst:127
185236
msgid "Namespace packages"
186-
msgstr ""
237+
msgstr "命名空間套件"
187238

188239
#: ../../reference/import.rst:133
189240
msgid ""
@@ -195,6 +246,10 @@ msgid ""
195246
"objects on the file system; they may be virtual modules that have no "
196247
"concrete representation."
197248
msgstr ""
249+
"命名空間套件是由不同的\\ :term:`部分 <portion>` 組成的,每個部分都為父套件提"
250+
"供一個子套件。這些部分可以位於檔案系統上的不同位置。部分可能也存在於壓縮檔案"
251+
"中、網路上,或 Python 在引入時搜尋的任何其他地方。命名空間套件不一定直接對應"
252+
"於檔案系統中的對象;它們可能是沒有具體表示的虛擬模組。"
198253

199254
#: ../../reference/import.rst:141
200255
msgid ""
@@ -204,6 +259,9 @@ msgid ""
204259
"that package if the path of their parent package (or :data:`sys.path` for a "
205260
"top level package) changes."
206261
msgstr ""
262+
"命名空間套件的 ``__path__`` 屬性不使用普通的串列。它們使用自定義的可疊代型"
263+
"別,當父套件的路徑(或頂層套件的 :data:`sys.path`)發生變化時,會在下一次引入"
264+
"嘗試時自動執行新一輪的套件部分搜尋。"
207265

208266
#: ../../reference/import.rst:147
209267
msgid ""
@@ -214,14 +272,19 @@ msgid ""
214272
"create a namespace package for the top-level ``parent`` package whenever it "
215273
"or one of its subpackages is imported."
216274
msgstr ""
275+
"在命名空間套件中,不存在 ``parent/__init__.py`` 檔案。實際上,在引入搜尋過程"
276+
"中可能會找到多個 ``parent`` 目錄,每個目錄由不同的部分提供。因此,``parent/"
277+
"one`` 可能與 ``parent/two`` 不會實際位於一起。在這種情況下,每當引入頂層 "
278+
"``parent`` 套件或其子套件之一時,Python 會為頂層 ``parent`` 套件建立一個命名"
279+
"空間套件。"
217280

218281
#: ../../reference/import.rst:154
219282
msgid "See also :pep:`420` for the namespace package specification."
220-
msgstr ""
283+
msgstr "有關命名空間套件的規範,請參見 :pep:`420`。"
221284

222285
#: ../../reference/import.rst:158
223286
msgid "Searching"
224-
msgstr ""
287+
msgstr "搜尋"
225288

226289
#: ../../reference/import.rst:160
227290
msgid ""
@@ -232,6 +295,10 @@ msgid ""
232295
"parameters to the :func:`importlib.import_module` or :func:`__import__` "
233296
"functions."
234297
msgstr ""
298+
"在開始搜尋之前,Python 需要被引入模組(或套件,但在本討論中,兩者的區別無關緊"
299+
"要)的完整\\ :term:`限定名稱 (qualified name) <qualified name>`。此名稱可能來"
300+
"自 :keyword:`import` 陳述式的各種引數,或來自 :func:`importlib."
301+
"import_module` 或 :func:`__import__` 函式的參數。"
235302

236303
#: ../../reference/import.rst:166
237304
msgid ""
@@ -241,10 +308,14 @@ msgid ""
241308
"baz``. If any of the intermediate imports fail, a :exc:`ModuleNotFoundError` "
242309
"is raised."
243310
msgstr ""
311+
"此名稱將在引入搜尋的各個階段中使用,並且它可能是指向子模組的點分隔路徑,例如 "
312+
"``foo.bar.baz``。在這種情況下,Python 會首先嘗試引入 ``foo``,然後是 ``foo."
313+
"bar``,最後是 ``foo.bar.baz``。如果任何中間引入失敗,則會引發 :exc:"
314+
"`ModuleNotFoundError`。"
244315

245316
#: ../../reference/import.rst:173
246317
msgid "The module cache"
247-
msgstr ""
318+
msgstr "模組快取"
248319

249320
#: ../../reference/import.rst:178
250321
msgid ""
@@ -255,6 +326,10 @@ msgid ""
255326
"and ``foo.bar.baz``. Each key will have as its value the corresponding "
256327
"module object."
257328
msgstr ""
329+
"在引入搜尋過程中首先檢查的地方是 :data:`sys.modules`。此對映用作所有先前引入"
330+
"過的模組的快取,包括中間路徑。因此,如果 ``foo.bar.baz`` 之前已被引入,:data:"
331+
"`sys.modules` 將包含 ``foo``、``foo.bar`` 和 ``foo.bar.baz`` 的條目。每個鍵的"
332+
"值都是相應的模組物件。"
258333

259334
#: ../../reference/import.rst:185
260335
msgid ""
@@ -264,6 +339,9 @@ msgid ""
264339
"`ModuleNotFoundError` is raised. If the module name is missing, Python will "
265340
"continue searching for the module."
266341
msgstr ""
342+
"在引入過程中,會在 :data:`sys.modules` 中查找模組名稱,如果存在,則相關的值為"
343+
"滿足此引入的模組,此引入過程即完成。然而,如果值是 ``None``,則會引發 :exc:"
344+
"`ModuleNotFoundError`。如果模組名稱不存在,Python 會繼續搜尋該模組。"
267345

268346
#: ../../reference/import.rst:191
269347
msgid ""
@@ -274,6 +352,10 @@ msgid ""
274352
"to ``None``, forcing the next import of the module to result in a :exc:"
275353
"`ModuleNotFoundError`."
276354
msgstr ""
355+
":data:`sys.modules` 是可寫入的。刪除一個鍵可能不會銷毀相關聯的模組(因為其他"
356+
"模組可能持有對它的參照),但會使指定的模組的快取條目失效,導致 Python 在下一"
357+
"次引入該模組時重新搜尋。也可以將鍵賦值為 ``None``,這會強制下一次引入該模組時"
358+
"引發 :exc:`ModuleNotFoundError`。"
277359

278360
#: ../../reference/import.rst:198
279361
msgid ""
@@ -283,10 +365,14 @@ msgid ""
283365
"reload` will reuse the *same* module object, and simply reinitialise the "
284366
"module contents by rerunning the module's code."
285367
msgstr ""
368+
"但請注意,如果你保留了對模組物件的參照,並在 :data:`sys.modules` 中使其快取條"
369+
"目失效,然後重新引入指定的模組,這兩個模組物件將\\ *不會*\\ 相同。相比之下,:"
370+
"func:`importlib.reload` 會重用\\ *相同的*\\ 模組物件,並透過重新執行模組的程"
371+
"式碼來簡單地重新初始化模組內容。"
286372

287373
#: ../../reference/import.rst:208
288374
msgid "Finders and loaders"
289-
msgstr ""
375+
msgstr "尋檢器 (Finder) 與載入器 (Loader)"
290376

291377
#: ../../reference/import.rst:215
292378
msgid ""
@@ -299,6 +385,11 @@ msgid ""
299385
"they return themselves when they find that they can load the requested "
300386
"module."
301387
msgstr ""
388+
"如果在 :data:`sys.modules` 中找不到指定的模組,則會調用 Python 的引入協定來尋"
389+
"找並載入該模組。這個協定由兩個概念性物件組成,:term:`尋檢器 <finder>` 和\\ :"
390+
"term:`載入器 <loader>`。尋檢器的任務是使用其已知的策略來確定是否能找到命名模"
391+
"組。實作這兩個介面的物件稱為\\ :term:`引入器 (importer) <importer>` ——當它們"
392+
"發現可以載入所請求的模組時,會回傳它們自己。"
302393

303394
#: ../../reference/import.rst:223
304395
msgid ""
@@ -309,12 +400,17 @@ msgid ""
309400
"system paths or zip files. It can also be extended to search for any "
310401
"locatable resource, such as those identified by URLs."
311402
msgstr ""
403+
"Python 包含多個預設的尋檢器和引入器。第一個尋檢器知道如何定位內建模組,第二個"
404+
"尋檢器知道如何定位凍結模組。第三個預設尋檢器會在 :term:`import path` 中搜尋模"
405+
"組。:term:`import path` 是一個位置的列表,這些位置可能是檔案系統路徑或壓縮檔"
406+
"案,也可以擴展以搜尋任何可定位的資源,例如由 URL 識別的資源。"
312407

313408
#: ../../reference/import.rst:230
314409
msgid ""
315410
"The import machinery is extensible, so new finders can be added to extend "
316411
"the range and scope of module searching."
317412
msgstr ""
413+
"引入機制是可擴展的,因此可以增加新的尋檢器來擴展模組搜尋的範圍和作用域。"
318414

319415
#: ../../reference/import.rst:233
320416
msgid ""
@@ -323,31 +419,41 @@ msgid ""
323419
"related information, which the import machinery then uses when loading the "
324420
"module."
325421
msgstr ""
422+
"尋檢器實際上不會載入模組。如果它們能找到指定的模組,它們會回傳一個\\ :dfn:`模"
423+
"組規格`,這是一個模組的引入相關資訊的封裝,引入機制會在載入模組時使用這些資"
424+
"訊。"
326425

327426
#: ../../reference/import.rst:237
328427
msgid ""
329428
"The following sections describe the protocol for finders and loaders in more "
330429
"detail, including how you can create and register new ones to extend the "
331430
"import machinery."
332431
msgstr ""
432+
"以下各節將更詳細地描述尋檢器和載入器的協定,包括如何建立和註冊新的尋檢器和載"
433+
"入器來擴展引入機制。"
333434

334435
#: ../../reference/import.rst:241
335436
msgid ""
336437
"In previous versions of Python, finders returned :term:`loaders <loader>` "
337438
"directly, whereas now they return module specs which *contain* loaders. "
338439
"Loaders are still used during import but have fewer responsibilities."
339440
msgstr ""
441+
"Python 在之前的版本中,尋檢器會直接回傳\\ :term:`載入器 <loader>`,而現在它們"
442+
"回傳的是\\ *包含*\\ 載入器的模組規格。載入器仍在引入過程中使用,但其責任減少"
443+
"了。"
340444

341445
#: ../../reference/import.rst:247
342446
msgid "Import hooks"
343-
msgstr ""
447+
msgstr "引入掛鉤 (Import hooks)"
344448

345449
#: ../../reference/import.rst:257
346450
msgid ""
347451
"The import machinery is designed to be extensible; the primary mechanism for "
348452
"this are the *import hooks*. There are two types of import hooks: *meta "
349453
"hooks* and *import path hooks*."
350454
msgstr ""
455+
"引入機制的設計是可擴展的;其主要機制是\\ *引入掛鉤*。引入掛鉤有兩種類型:*元"
456+
"掛鉤 (meta hooks)* 和\\ *引入路徑掛鉤*。"
351457

352458
#: ../../reference/import.rst:261
353459
msgid ""
@@ -357,6 +463,10 @@ msgid ""
357463
"modules, or even built-in modules. Meta hooks are registered by adding new "
358464
"finder objects to :data:`sys.meta_path`, as described below."
359465
msgstr ""
466+
"元掛鉤會在引入處理的開始階段被呼叫,除了查找 :data:`sys.modules` 快取外,其他"
467+
"引入處理還未發生時就會呼叫。這允許元掛鉤覆蓋 :data:`sys.path` 的處理、凍結模"
468+
"組,甚至是內建模組。元掛鉤透過將新的尋檢器物件添加到 :data:`sys.meta_path` 中"
469+
"來註冊,具體描述請參閱以下段落。"
360470

361471
#: ../../reference/import.rst:267
362472
msgid ""
@@ -365,10 +475,13 @@ msgid ""
365475
"encountered. Import path hooks are registered by adding new callables to :"
366476
"data:`sys.path_hooks` as described below."
367477
msgstr ""
478+
"引入路徑掛鉤被視為 :data:`sys.path`\\ (或 ``package.__path__``)處理過程的一"
479+
"部分來呼叫,當遇到與其相關聯的路徑項目時就會被觸發。引入路徑掛鉤透過將新的可"
480+
"呼叫對象增加到 :data:`sys.path_hooks` 中來註冊,具體描述請參閱以下段落。"
368481

369482
#: ../../reference/import.rst:274
370483
msgid "The meta path"
371-
msgstr ""
484+
msgstr "元路徑"
372485

373486
#: ../../reference/import.rst:280
374487
msgid ""
@@ -381,6 +494,11 @@ msgid ""
381494
"finder can use any strategy it wants to determine whether it can handle the "
382495
"named module or not."
383496
msgstr ""
497+
"當在 :data:`sys.modules` 中找不到命名模組時,Python 接下來會搜尋 :data:`sys."
498+
"meta_path`,其中包含一個元路徑尋檢器物件串列。這些尋檢器會依次被查詢,看它們"
499+
"是否知道如何處理命名模組。元路徑尋檢器必須實作一個名為 :meth:`~importlib.abc."
500+
"MetaPathFinder.find_spec` 的方法,該方法接收三個引數:名稱、引入路徑和(可選"
501+
"的)目標模組。元路徑尋檢器可以使用任何策略來確定它是否能處理命名模組。"
384502

385503
#: ../../reference/import.rst:289
386504
msgid ""
@@ -390,6 +508,10 @@ msgid ""
390508
"returning a spec, then a :exc:`ModuleNotFoundError` is raised. Any other "
391509
"exceptions raised are simply propagated up, aborting the import process."
392510
msgstr ""
511+
"如果元路徑尋檢器知道如何處理命名模組,它會回傳一個規格物件。如果它無法處理命"
512+
"名模組,則回傳 ``None``。如果 :data:`sys.meta_path` 的處理到達串列的末尾仍未"
513+
"回傳規格,則會引發 :exc:`ModuleNotFoundError`。任何其他引發的例外將直接向上傳"
514+
"播,並中止引入過程。"
393515

394516
#: ../../reference/import.rst:295
395517
msgid ""
@@ -404,6 +526,12 @@ msgid ""
404526
"existing module object that will be the target of loading later. The import "
405527
"system passes in a target module only during reload."
406528
msgstr ""
529+
"元路徑尋檢器的 :meth:`~importlib.abc.MetaPathFinder.find_spec` 方法會以兩個或"
530+
"三個引數來呼叫。第一個是被引入模組的完全限定名稱,例如 ``foo.bar.baz``。第二"
531+
"個引數是用於模組搜尋的路徑條目。對於頂層模組,第二個引數是 ``None``,但對於子"
532+
"模組或子套件,第二個引數是父套件的 ``__path__`` 屬性的值。如果無法存取相應的 "
533+
"``__path__`` 屬性,將引發 :exc:`ModuleNotFoundError`。第三個引數是一個現有的"
534+
"模組物件,該物件將成為後續載入的目標。引入系統只會在重新載入時傳入目標模組。"
407535

408536
#: ../../reference/import.rst:306
409537
msgid ""
@@ -416,13 +544,21 @@ msgid ""
416544
"__path__, None)``. Once ``foo.bar`` has been imported, the final traversal "
417545
"will call ``mpf.find_spec(\"foo.bar.baz\", foo.bar.__path__, None)``."
418546
msgstr ""
547+
"對於一個引入請求,元路徑可能會被遍歷多次。例如,假設參與的模組都沒有被快取,"
548+
"則引入 ``foo.bar.baz`` 將首先執行頂層引入,對每個元路徑尋檢器(``mpf``)呼叫 "
549+
"``mpf.find_spec(\"foo\", None, None)``。當 ``foo`` 被引入後,將再次藉由遍歷元"
550+
"路徑引入 ``foo.bar``,並呼叫 ``mpf.find_spec(\"foo.bar\", foo.__path__, "
551+
"None)``。當 ``foo.bar`` 被引入後,最後一次遍歷會呼叫 ``mpf.find_spec(\"foo."
552+
"bar.baz\", foo.bar.__path__, None)``。"
419553

420554
#: ../../reference/import.rst:316
421555
msgid ""
422556
"Some meta path finders only support top level imports. These importers will "
423557
"always return ``None`` when anything other than ``None`` is passed as the "
424558
"second argument."
425559
msgstr ""
560+
"一些元路徑尋檢器僅支援頂層引入。當第二個引數傳入 ``None`` 以外的值時,這些引"
561+
"入器將始終回傳 ``None``。"
426562

427563
#: ../../reference/import.rst:320
428564
msgid ""
@@ -431,6 +567,9 @@ msgid ""
431567
"modules, and one that knows how to import modules from an :term:`import "
432568
"path` (i.e. the :term:`path based finder`)."
433569
msgstr ""
570+
"Python 的預設 :data:`sys.meta_path` 有三個元路徑尋檢器,一個知道如何引入內建"
571+
"模組,一個知道如何引入凍結模組,還有一個知道如何從 :term:`import path` 引入模"
572+
"組(即 :term:`path based finder`)。"
434573

435574
#: ../../reference/import.rst:325
436575
msgid ""
@@ -440,18 +579,23 @@ msgid ""
440579
"if the finder does not implement :meth:`~importlib.abc.MetaPathFinder."
441580
"find_spec`."
442581
msgstr ""
582+
"元路徑尋檢器的 :meth:`~importlib.abc.MetaPathFinder.find_spec` 方法取代了 :"
583+
"meth:`!find_module`,後者現在已被棄用。雖然它將繼續正常工作,但引入機制僅在尋"
584+
"檢器未實作 :meth:`~importlib.abc.MetaPathFinder.find_spec` 時才會嘗試使用它。"
443585

444586
#: ../../reference/import.rst:332
445587
msgid ""
446588
"Use of :meth:`!find_module` by the import system now raises :exc:"
447589
"`ImportWarning`."
448-
msgstr ""
590+
msgstr "引入系統現在使用 :meth:`!find_module` 時將引發 :exc:`ImportWarning`。"
449591

450592
#: ../../reference/import.rst:336
451593
msgid ""
452594
":meth:`!find_module` has been removed. Use :meth:`~importlib.abc."
453595
"MetaPathFinder.find_spec` instead."
454596
msgstr ""
597+
":meth:`!find_module` 已被移除。請改用 :meth:`~importlib.abc.MetaPathFinder."
598+
"find_spec`。"
455599

456600
#: ../../reference/import.rst:342
457601
msgid "Loading"

0 commit comments

Comments
 (0)
Please sign in to comment.