>>> from pathlib import Path >>> p = Path("/home/user/Downloads/repo/test.txt") >>> print(p.stem) test >>> print(p.name) test.txt