The file executing
Benjamin
musiccomposition at gmail.com
Fri Jul 6 16:15:22 EDT 2007
On Jul 3, 8:56 am, Sebastian Wiesner <basti.wies... at gmx.net> wrote:
> [ Benjamin <musiccomposit... at gmail.com> ]
>
> > On Jul 2, 9:47 pm, Justin Ezequiel <justin.mailingli... at gmail.com>
>
> > wrote:
> > > On Jul 3, 9:40 am, Benjamin <musiccomposit... at gmail.com> wrote:
> > > > How does one get the path to the file currently executing (not the
> > > > cwd). Thank you
>
> > > os.path.dirname(sys.argv[0])
>
> > The returns the file that was called first, but not the one currently
> > executing...
>
> Use __file__ instead of sys.argv[0]
So:
if __name__ == "main":
currentDir = os.path.dirname(sys.argv[0])
else:
currentDir = os.path.dirname(__file__)
>
> --
> Freedom is always the freedom of dissenters.
> (Rosa Luxemburg)
>
> signature.asc
> 1KDownload
More information about the Python-list
mailing list