Use this to get the path of the current file. It will resolve any symlinks in the path.
import os
file_path = os.path.realpath(__file__)
This works fine on my mac. It won't work from the Python interpreter (you need to be executing a Python file).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…