(prefix, path)
return os.path.commonprefix([prefix, path]) == prefix
Is `path` contained within the directory `prefix`.

    >>> isprefixed("/usr/local/", "/usr/local/shared")
    True
Is `path` contained within the directory `prefix`.
Is path contained within the directory prefix .
def isprefixed(prefix, path):
    """
    Is `path` contained within the directory `prefix`.

    >>> isprefixed("/usr/local/", "/usr/local/shared")
    True
    """
    normalize = lambda path: os.path.normcase(os.path.normpath(path))
    prefix, path = normalize(prefix), normalize(path)
    if not prefix.endswith(os.path.sep):
        prefix = prefix + os.path.sep
    return os.path.commonprefix([prefix, path]) == prefix
def isprefixed ( prefix , path ) : normalize = lambda path : os . path . normcase ( os . path . normpath ( path ) ) prefix , path = normalize ( prefix ) , normalize ( path ) if not prefix . endswith ( os . path . sep ) : prefix = prefix + os . path . sep return os . path . commonprefix ( [ prefix , path ] ) == prefix