С помощью библиотеки pathlib вы можете сократить длину кода, задав переменную «домашний путь» (home):
from pathlib import Pathhome = Path.home()file = home / "treasure_map.txt"file.touch()print(f"Ваш файл злесь: {file}")#лучшиепрактики
ZE Zen of Python @zen_of_python · 18.8K subscribers from pathlib import Pathhome = Path.home()file = home / "treasure_map.txt"file.touch()print(f"Ваш файл злесь: {file}")