def filenameToModule(fn):
 if (not os.path.exists(fn)):
  raise ValueError(("%r doesn't exist" % (fn,)))
 try:
  ret = reflect.namedAny(reflect.filenameToModuleName(fn))
 except (ValueError, AttributeError):
  return _importFromFile(fn)
 retFile = (os.path.splitext(ret.__file__)[0] + '.py')
 same = getattr(os.path, 'samefile', samefile)
 if (os.path.isfile(fn) and (not same(fn, retFile))):
  del sys.modules[ret.__name__]
  ret = _importFromFile(fn)
 return ret

def filenameToModule ( fn ) : if ( not os . path . exists ( fn ) ) : raise ValueError ( ( "%r doesn't exist" % ( fn , ) ) ) try : ret = reflect . namedAny ( reflect . filenameToModuleName ( fn ) ) except ( ValueError , AttributeError ) : return _importFromFile ( fn ) retFile = ( os . path . splitext ( ret . __file__ ) [ 0 ] + '.py' ) same = getattr ( os . path , 'samefile' , samefile ) if ( os . path . isfile ( fn ) and ( not same ( fn , retFile ) ) ) : del sys . modules [ ret . __name__ ] ret = _importFromFile ( fn ) return ret
given a filename .