How to get the path of current running python script?

Tim Williams (gmail) tdwdotnet at gmail.com
Tue Dec 20 07:37:25 EST 2005


On 20/12/05, Kevin Yuan <farproc at gmail.com> wrote:
>
> I tried the following
>
> >>>> getFilePath = lambda name: os.path.normpath('%s\\%s' % (sys.modules[name].prefix,
> sys.modules[name].__name__))
> >>>> getFilePath('__main__')
>


getFilePath =  sys.argv[0]    ??


:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051220/ea6090f8/attachment.html>


More information about the Python-list mailing list