All pastes #908351 Raw Edit

Something

public python v1 · immutable
·published 2008-02-18 11:08 UTC
rendered paste body
import os, impdef valid_python_suffix(file):    for suffix in [i[0] for i in imp.get_suffixes()]:        if file.endswith(suffix):            return True    return Falsedef execute_file(file):    if not file or not valid_python_suffix(file):        raise Exception('Not a python file argument given')    path = os.path.abspath(file)    dirname = os.path.dirname(path)    filename = os.path.basename(path)    modulename = filename.replace('.py', '')    info = imp.find_module(modulename, [dirname, ])    module = imp.load_module(modulename , *info)def main():    execute_file('print.py')if __name__ == '__main__':    main()