from pathlib import Path def resolve_path(*p: str): return Path(*p).expanduser().resolve().absolute() def safe_list_get(l, idx, default): """ https://stackoverflow.com/a/5125636 :param l: :param idx: :param default: :return: """ try: return l[idx] except IndexError: return default