How to get full path to script?

Mark Tolonen M8R-yfto6h at
Sun Jun 8 20:45:35 CEST 2008

"kj" <socyl at> wrote in message 
news:g2h3do$74t$1 at
> How can a script know its absolute path?  (__file__ only gives the
> path it was used to invoke the script.)
> Basically, I'm looking for the Python equivalent of Perl's FindBin.
> The point of all this is to make the scripts location the reference
> point for the location of other files, as part of a self-contained
> distribution.
> TIA!
> Kynn
> -- 
> NOTE: In my address everything before the first period is backwards;
> and the last period, and everything after it, should be discarded.

import os
print os.path.abspath(__file__)


More information about the Python-list mailing list