how to get current file name in python code example
Example 1: python get script name
from pathlib import Path
Path(__file__).name
Path(__file__).stem
import os
os.path.basename(__file__)
os.path.splitext(os.path.basename(__file__))[0]
Example 2: python name of current file
from pathlib import Path
print(Path(__file__).stem)
print(Path(__file__).name)
Example 3: get the name of a current script in python
Use __file__. If you want to omit the directory part (which might be present), you can use os.path.basename(__file__)