Back to module index

Go to module by name

runpy

runpy.py - locating and running Python code using the module namespace

Provides support for locating and running Python scripts using the Python
module namespace instead of the native filesystem.

This allows Python code to play nicely with non-filesystem based PEP 302
importers when locating support scripts as well as when importing modules.

Functions

get_importer

get_importer(path_item)

  Retrieve a finder for the given path item

      The returned finder is cached in sys.path_importer_cache
      if it was newly created by a path hook.

      The cache (or part of it) can be cleared manually if a
      rescan of sys.path_hooks is necessary.
    

read_code

read_code(stream)

run_module

run_module(mod_name, init_globals=None, run_name=None, alter_sys=False)

  Execute a module's code without importing it

         Returns the resulting top level namespace dictionary
    

run_path

run_path(path_name, init_globals=None, run_name=None)

  Execute code located at the specified filesystem location

         Returns the resulting top level namespace dictionary

         The file path may refer directly to a Python script (i.e.
         one that could be directly executed with execfile) or else
         it may refer to a zipfile or directory containing a top
         level __main__.py script.
    

Modules

importlib

io

os

sys

types