(path)
Import all modules from the given directory
Import all modules from the given directory
Import all modules from the given directory
def load_modules_from_path(path):
    """
    Import all modules from the given directory
    """
    # Check and fix the path
    if path[-1:] != '/':
        path += '/'

    # Get a list of files in the directory, if the directory exists
    if not os.path.exists(path):
        raise OSError("Directory does not exist: %s" % path)

    # Add path to the system path
    sys.path.append(path)
    # Load all the files in path
    for f in os.listdir(path):
        # Ignore anything that isn't a .py file
        if len(f) > 3 and f[-3:] == '.py':
            modname = f[:-3]
            # Import the module
            __import__(modname, globals(), locals(), ['*'])
def load_modules_from_path ( path ) : # Check and fix the path if path [ - 1 : ] != '/' : path += '/' # Get a list of files in the directory, if the directory exists if not os . path . exists ( path ) : raise OSError ( "Directory does not exist: %s" % path ) # Add path to the system path sys . path . append ( path ) # Load all the files in path for f in os . listdir ( path ) : # Ignore anything that isn't a .py file if len ( f ) > 3 and f [ - 3 : ] == '.py' : modname = f [ : - 3 ] # Import the module __import__ ( modname , globals ( ) , locals ( ) , [ '*' ] )