Get Path of current Script

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Mar 14 05:51:25 EDT 2011


On Mon, 14 Mar 2011 02:25:46 -0700, Alexander Schatten wrote:

> is there an easy way (API) to get the directory of the currently running
> script? 

import __main__
import os
print os.path.dirname(__main__.__file__)


-- 
Steven



More information about the Python-list mailing list