Function for the path of the script?

Gary Herron gary.herron at islandtraining.com
Sat Oct 26 22:52:31 EDT 2013


On 10/26/2013 07:23 PM, Peter Cacioppi wrote:
> Am I the only one who finds this function super useful?
>
> def _code_file() :
>      return os.path.abspath(inspect.getsourcefile(_code_file))
>
>
> I've got one in every script. It's the only one I have to copy around. For my workflow ... so handy.
>
> I've got os.path.dirname aliased to dn, so its dn(_code_file()) that I find myself reaching for fairly often...

Huh?  In what kind of a workflow are you running a python file without 
knowing *what* file you are runnung?

Or am I just misinterpreting what this code does?

Confused but curious,
Gary Herron




More information about the Python-list mailing list