Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6ae880

Browse files
committed
feat: to rst:198
1 parentaf7963e commite6ae880

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

‎reference/import.po

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgstr ""
77
"Project-Id-Version:Python 3.13\n"
88
"Report-Msgid-Bugs-To:\n"
99
"POT-Creation-Date:2024-09-03 11:11+0800\n"
10-
"PO-Revision-Date:2024-10-0311:47+0800\n"
10+
"PO-Revision-Date:2024-10-0312:02+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"
@@ -47,7 +47,7 @@ msgid ""
4747
"operation."
4848
msgstr""
4949
":keyword:`import` 陳述式結合了兩個操作:首先搜尋指定的模組,然後將搜尋結果繫"
50-
"結到本地作用域中的一個名稱。:keyword:`!import`陳述式的搜索操作被定義為一個"
50+
"結到本地作用域中的一個名稱。:keyword:`!import`陳述式的搜尋操作被定義為一個"
5151
"對 :func:`__import__` 函式的呼叫,並帶有相應的引數。:func:`__import__` 的回傳"
5252
"值用於執行 :keyword:`!import` 陳述式的名稱繫結操作。有關名稱繫結操作的詳細資"
5353
"訊,請參見 :keyword:`!import` 陳述式。"
@@ -248,7 +248,7 @@ msgid ""
248248
msgstr""
249249
"命名空間套件是由不同的\\ :term:`部分 <portion>` 組成的,每個部分都為父套件提"
250250
"供一個子套件。這些部分可以位於檔案系統上的不同位置。部分可能也存在於壓縮檔案"
251-
"中、網路上,或 Python在引入時搜索的任何其他地方。命名空間套件不一定直接對應"
251+
"中、網路上,或 Python在引入時搜尋的任何其他地方。命名空間套件不一定直接對應"
252252
"於檔案系統中的對象;它們可能是沒有具體表示的虛擬模組。"
253253

254254
#:../../reference/import.rst:141
@@ -261,7 +261,7 @@ msgid ""
261261
msgstr""
262262
"命名空間套件的 ``__path__`` 屬性不使用普通的串列。它們使用自定義的可疊代型"
263263
"別,當父套件的路徑(或頂層套件的 :data:`sys.path`)發生變化時,會在下一次引入"
264-
"嘗試時自動執行新一輪的套件部分搜索。"
264+
"嘗試時自動執行新一輪的套件部分搜尋。"
265265

266266
#:../../reference/import.rst:147
267267
msgid""
@@ -272,7 +272,7 @@ msgid ""
272272
"create a namespace package for the top-level ``parent`` package whenever it "
273273
"or one of its subpackages is imported."
274274
msgstr""
275-
"在命名空間套件中,不存在 ``parent/__init__.py`` 檔案。實際上,在引入搜索過程"
275+
"在命名空間套件中,不存在 ``parent/__init__.py`` 檔案。實際上,在引入搜尋過程"
276276
"中可能會找到多個 ``parent`` 目錄,每個目錄由不同的部分提供。因此,``parent/"
277277
"one`` 可能與 ``parent/two`` 不會實際位於一起。在這種情況下,每當引入頂層 "
278278
"``parent`` 套件或其子套件之一時,Python 會為頂層 ``parent`` 套件建立一個命名"
@@ -284,7 +284,7 @@ msgstr "有關命名空間套件的規範,請參見 :pep:`420`。"
284284

285285
#:../../reference/import.rst:158
286286
msgid"Searching"
287-
msgstr""
287+
msgstr"搜尋"
288288

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

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

308316
#:../../reference/import.rst:173
309317
msgid"The module cache"
310-
msgstr""
318+
msgstr"模組快取"
311319

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

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

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

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

350373
#:../../reference/import.rst:208
351374
msgid"Finders and loaders"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp