In Python 3.4+, you can use the pathlib module (included in Python's standard library):
pathlib
>>> from pathlib import Path >>> p = Path("/home/user/Downloads/repo/test.txt") >>> print(p.stem) test >>> print(p.name) test.txt
1.4m articles
1.4m replys
5 comments
57.0k users