def is_relative(modname, from_file):
 if (not os.path.isdir(from_file)):
  from_file = os.path.dirname(from_file)
 if (from_file in sys.path):
  return False
 try:
  (stream, _, _) = imp.find_module(modname.split('.')[0], [from_file])
  if stream:
   stream.close()
  return True
 except ImportError:
  return False

def is_relative ( modname , from_file ) : if ( not os . path . isdir ( from_file ) ) : from_file = os . path . dirname ( from_file ) if ( from_file in sys . path ) : return False try : ( stream , _ , _ ) = imp . find_module ( modname . split ( '.' ) [ 0 ] , [ from_file ] ) if stream : stream . close ( ) return True except ImportError : return False
return true if the given module name is relative to the given file name :type modname: str .