Peter Cacioppi <peter.cacio...@gmail.com> writes:

> Am I the only one who finds this function super useful?
>
> def _code_file() :
>     return os.path.abspath(inspect.getsourcefile(_code_file))

I've used ‘os.path.dirname(os.path.abspath(__file__))’ to find the
directory containing the current file, in the past. But that was before
Python's ‘unittest’ module could discover where the test code lives.

> I've got one in every script. It's the only one I have to copy around.
> For my workflow ... so handy.

What workflow requires you to know the filename of the module, within
the module?

-- 
 \                              “Time wounds all heels.” —Groucho Marx |
  `\                                                                   |
_o__)                                                                  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to