I\'m building a simple helper script for work that will copy a couple of template files in our code base to the current directory. I don\'t, however, have the absolute path
This code will return the absolute path to the main script.
import os def whereAmI(): return os.path.dirname(os.path.realpath(__import__("__main__").__file__))
This will work even in a module.