How to get the path of current running python script?

Kevin Yuan farproc at gmail.com
Tue Dec 20 07:15:57 EST 2005


I tried the following

>>>> getFilePath = lambda name: os.path.normpath('%s\\%s' %
(sys.modules[name].prefix,
sys.modules[name].__name__))
>>>> getFilePath('__main__')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "<interactive input>", line 1, in <lambda>
AttributeError: 'module' object has no attribute 'prefix'
>>>>

Can you help me?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051220/992a54e0/attachment.html>


More information about the Python-list mailing list