@@ -204,16 +204,22 @@ msgid ""
204204"section of the :mod:`importlib` documentation for details of the various "
205205"approaches."
206206msgstr ""
207+ "如果之前是与 :func:`imp.find_module` 一起使用则可考虑使用 "
208+ ":func:`importlib.import_module`,在其他情况下请使用你选择的 :func:`imp.find_module` "
209+ "替代品所返回的加载器。 如果你直接附带文件路径参数调用 :func:`imp.load_module` 和相关函数则请使用 "
210+ ":func:`importlib.util.spec_from_file_location` 和 "
211+ ":func:`importlib.util.module_from_spec` 的组合。 参见 :mod:`importlib` 文档的 "
212+ ":ref:`importlib-examples` 小节来了解各种方式的细节。"
207213
208214#: ../../library/imp.rst:126
209215msgid ""
210216"Return a new empty module object called *name*. This object is *not* "
211217"inserted in ``sys.modules``."
212- msgstr ""
218+ msgstr "返回一个新的名为 *name* 的空模块对象。 此对象 *不会* 被插入到 ``sys.modules`` 中。 "
213219
214220#: ../../library/imp.rst:129
215221msgid "Use :func:`importlib.util.module_from_spec` instead."
216- msgstr ""
222+ msgstr "请改用 :func:`importlib.util.module_from_spec`。 "
217223
218224#: ../../library/imp.rst:135
219225msgid ""
@@ -223,6 +229,9 @@ msgid ""
223229"to try out the new version without leaving the Python interpreter. The "
224230"return value is the module object (the same as the *module* argument)."
225231msgstr ""
232+ "重新加载之前导入的 *module*。 该参数必须是一个模块对象,因此它之前必须已经被成功导入了。 "
233+ "这在当你已使用外部编辑器编辑过模块源代码文件并想在不退出 Python 解释器的情况下尝试新版本时会很有用处。 返回值为模块对象(与 *module* "
234+ "参数所指向的相同)。"
226235
227236#: ../../library/imp.rst:141
228237msgid "When ``reload(module)`` is executed:"
@@ -235,6 +244,8 @@ msgid ""
235244"dictionary. The ``init`` function of extension modules is not called a "
236245"second time."
237246msgstr ""
247+ "Python 模块的代码会被重新编译并且模块层级的代码将重新执行,定义一个新的绑定到模块字典中的名称的对象集合。 扩展模块的 ``init`` "
248+ "函数不会被重复调用。"
238249
239250#: ../../library/imp.rst:148
240251msgid ""
@@ -281,6 +292,8 @@ msgid ""
281292"to be initialized more than once, and may fail in arbitrary ways when "
282293"reloaded."
283294msgstr ""
295+ "重新加载内置或动态加载的模块是合法操作但通常不是很有用处,除非是 :mod:`sys`, :mod:`__main__` 和 "
296+ ":mod:`builtins`。 但是在许多情况下,扩展模块并不是被设计为可被多次初始化的,并可能在重新加载时以任意方式失败。"
284297
285298#: ../../library/imp.rst:178
286299msgid ""
@@ -290,6 +303,9 @@ msgid ""
290303"execute the :keyword:`!from` statement, another is to use :keyword:`!import`"
291304" and qualified names (*module*.*name*) instead."
292305msgstr ""
306+ "如果一个模块使用 :keyword:`from` ... :keyword:`import` ... 导入来自另一个模块的对象,则为另一个模块调用 "
307+ ":func:`reload` 并不会重新定义从其中导入的对象 --- 绕过此问题的一种方式是重新执行 :keyword:`!from` "
308+ "语句,另一种方式是使用 :keyword:`!import` 和限定名称 (*module*.*name*) 来代替。"
293309
294310#: ../../library/imp.rst:184
295311msgid ""
@@ -303,11 +319,11 @@ msgstr "如果一个模块创建一个类的实例,重新加载定义那个类
303319msgid ""
304320"Relies on both ``__name__`` and ``__loader__`` being defined on the module "
305321"being reloaded instead of just ``__name__``."
306- msgstr ""
322+ msgstr "依赖于 ``__name__`` 和 ``__loader__`` 而不仅是 ``__name__`` 同时定义在被重新加载的模块上。 "
307323
308324#: ../../library/imp.rst:192
309325msgid "Use :func:`importlib.reload` instead."
310- msgstr ""
326+ msgstr "使用 :func:`importlib.reload` 来代替。 "
311327
312328#: ../../library/imp.rst:196
313329msgid ""
0 commit comments