import os absolute_path = os.path.abspath(__file__) print(absolute_path) dir_name = os.path.dirname(absolute_path) print(dir_name) import inspect absolute_path = inspect.getfile(inspect.currentframe()) print(absolute_path) dir_name = os.path.dirname(absolute_path) print(dir_name)