__file__
is the path of the Python script.
Note that if you make a sybolic link to a Python script and run the symbolic link,
then __file__
is the path of the symbolic link.
Of course, you can use os.path.realpath
to get real path of files.
pathlib.Path …