def path_is_inside(path, dirname):
path = os.path.abspath(path)<EOL>dirname = os.path.abspath(dirname)<EOL>while len(path) >= len(dirname):<EOL><INDENT>if path == dirname:<EOL><INDENT>return True<EOL><DEDENT>newpath = os.path.dirname(path)<EOL>if newpath == path:<EOL><INDENT>return False<EOL><DEDENT>path = newpath<EOL><DEDENT>return False<EOL>
Return True if path is under dirname.