def importfile(path):
 magic = imp.get_magic()
 file = open(path, 'r')
 if (file.read(len(magic)) == magic):
  kind = imp.PY_COMPILED
 else:
  kind = imp.PY_SOURCE
 file.close()
 filename = os.path.basename(path)
 (name, ext) = os.path.splitext(filename)
 file = open(path, 'r')
 try:
  module = imp.load_module(name, file, path, (ext, 'r', kind))
 except:
  raise ErrorDuringImport(path, sys.exc_info())
 file.close()
 return module

def importfile ( path ) : magic = imp . get_magic ( ) file = open ( path , 'r' ) if ( file . read ( len ( magic ) ) == magic ) : kind = imp . PY_COMPILED else : kind = imp . PY_SOURCE file . close ( ) filename = os . path . basename ( path ) ( name , ext ) = os . path . splitext ( filename ) file = open ( path , 'r' ) try : module = imp . load_module ( name , file , path , ( ext , 'r' , kind ) ) except : raise ErrorDuringImport ( path , sys . exc_info ( ) ) file . close ( ) return module
import a python source file or compiled file given its path .