import os os.path.dirname(os.path.abspath(__file__))
import os # you have to be in the same directory as the file file = 'myfile.txt' # or also file = 'directory/to/myfile.txt' path = os.path.abspath(file)
import os os.path.abspath(os.getcwd())
import pathlib pathlib.Path(__file__).parent.absolute()
import os print('getcwd: ', os.getcwd()) print('__file__: ', __file__)
import os print os.path.abspath("something.exe")