Simple way to get the full path of a running script?

Benjamin Han bhan at andrew.cmu.edu
Sun Dec 28 01:12:06 CET 2003


Should be:

pathToScript=\
  os.path.normpath(os.path.join(os.getcwd(),os.path.split(sys.argv[0])[0]))

On Sat, 27 Dec 2003, Benjamin Han wrote:

> Duh - the way I described seems to be simple enough:
>
> pathToScript=os.join(os.getcwd(),os.path.split(sys.argv[0])[0])
>
>
> On Sat, 27 Dec 2003, Benjamin Han wrote:
>
> > I know I can do this by get sys.argv[0], tell if it's a full path, and if not,
> > somehow join the relative path with getcwd(). Just wondering if there's a
> > simpler way to do this. Thanks!
> >
>




More information about the Python-list mailing list