Get location of the .py source file
In Python +3.4 use of pathlib is more handy:
from pathlib import Path
source_path = Path(__file__).resolve()
source_dir = source_path.parent
# in /a/b/c/d/e/file.py
import os
os.path.dirname(os.path.abspath(__file__)) # /a/b/c/d/e