20 lines
342 B
Python
20 lines
342 B
Python
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
|