To get current file's full path, you can use the os.path.abspath function. If you want only the directory path, you can call os.path.dirname.
Example
import os absolute_path = os.path.abspath(__file__) print("Full path: " + absolute_path) print("Directory Path: " + os.path.dirname(absolute_path))
Output
This will give the output:
Full path: C:\\python27\\test.py Directory path: C:\\python27\\