Nom python du fichier actuel
from pathlib import Path
print(Path(__file__).stem) #myfile
print(Path(__file__).name) #myfile.py
Annoying Armadillo
from pathlib import Path
print(Path(__file__).stem) #myfile
print(Path(__file__).name) #myfile.py
import os
os.path.basename(__file__)
Use __file__. If you want to omit the directory part (which might be present), you can use os.path.basename(__file__)