What is a best way in Python to hint a filename,
so that it's acceptable to pass anything into a function that you can open as a file?
Especially both strings and files found via Pathlib.
def myfunc(filename: str) -> None:
with open(filename) as f1:
# do something here
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…