Simple way to get the full path of a running script?
Isr Gish
isrgish at fusemail.com
Mon Jan 5 21:04:39 EST 2004
-----Original Message-----
>From: "Hartmut Goebel" Wrote:
>> import inspect
>> print inspect.getsourcefile( lambda:None )
>
>Nice idea!
>
>Enhancement: when using inspect.getfile() the snippet will work even for
>module without sourcefile, too.
>
These 2 ways will give .py even if .pyc was run.
There are 2 more options:
1) sys.argv[0]
2) __file__
Isr Gish
More information about the Python-list
mailing list