The accepted solution for this will not work if you are planning to compile your scripts using py2exe. If you're planning to do so, this is the functional equivalent:
os.path.dirname(sys.argv[0])
Py2exe does not provide an __file__
variable. For reference: http://www.py2exe.org/index.cgi/Py2exeEnvironment