code: def get_parent_dir(base_dir, level=1):
      "Get the directory $level levels above $base_dir."
      while level > 0:
          base_dir = os.path.dirname(base_dir)
          level -= 1
      return base_dif get_parent_dir(base_dir, level=1):
      "Get the directory $level levels above $base_dir."
      while level > 0:
          base_dir = os.path.dirname(base_dir)
          level -= 1
      return base_dir
docs: Get the directory $level levels above $base_dir.