3Usage: deepestdir [<ROOT>]
5Prints the path to the deepest directory under the given root. If no root
6is given, the current directory is used. If there are multiple directories
7at the same depth, only one is printed.
15def get_dir_paths_under(root):
16 """Generates the paths to every directory under ``root``."""
17 for dirpath, dirnames, _ in os.walk(root):
19 yield os.path.join(dirpath, d)
23def directory_depth(d):
24 """Returns the depth of a directory in the filesystem."""
25 if os.path.dirname(d) == d:
28 return 1 + directory_depth(os.path.dirname(d))
31if __name__ == "__main__":
37 print(max(get_dir_paths_under(root), key=directory_depth))