@@ -200,9 +200,24 @@ def _run_module_as_main(mod_name, alter_argv=True):
200200
201201def run_module (mod_name , init_globals = None ,
202202 run_name = None , alter_sys = False ):
203- """Execute a module's code without importing it
203+ """Execute a module's code without importing it.
204204
205- Returns the resulting top level namespace dictionary
205+ mod_name -- an absolute module name or package name.
206+
207+ Optional arguments:
208+ init_globals -- dictionary used to pre-populate the module’s
209+ globals dictionary before the code is executed.
210+
211+ run_name -- if not None, this will be used for setting __name__;
212+ otherwise, __name__ will be set to mod_name + '__main__' if the
213+ named module is a package and to just mod_name otherwise.
214+
215+ alter_sys -- if True, sys.argv[0] is updated with the value of
216+ __file__ and sys.modules[__name__] is updated with a temporary
217+ module object for the module being executed. Both are
218+ restored to their original values before the function returns.
219+
220+ Returns the resulting module globals dictionary.
206221 """
207222 mod_name , mod_spec , code = _get_module_details (mod_name )
208223 if run_name is None :
@@ -245,14 +260,19 @@ def _get_code_from_file(run_name, fname):
245260 return code , fname
246261
247262def run_path (path_name , init_globals = None , run_name = None ):
248- """Execute code located at the specified filesystem location
263+ """Execute code located at the specified filesystem location.
264+
265+ path_name -- filesystem location of a Python script, zipfile,
266+ or directory containing a top level __main__.py script.
267+
268+ Optional arguments:
269+ init_globals -- dictionary used to pre-populate the module’s
270+ globals dictionary before the code is executed.
249271
250- Returns the resulting top level namespace dictionary
272+ run_name -- if not None, this will be used to set __name__;
273+ otherwise, '<run_path>' will be used for __name__.
251274
252- The file path may refer directly to a Python script (i.e.
253- one that could be directly executed with execfile) or else
254- it may refer to a zipfile or directory containing a top
255- level __main__.py script.
275+ Returns the resulting module globals dictionary.
256276 """
257277 if run_name is None :
258278 run_name = "<run_path>"
0 commit comments