[Python-ideas] os.path.here()
Giampaolo Rodola'
g.rodola at gmail.com
Wed Feb 19 18:18:55 CET 2014
On Wed, Feb 19, 2014 at 6:04 PM, Oscar Benjamin
<oscar.j.benjamin at gmail.com>wrote:
> On 19 February 2014 16:52, Giampaolo Rodola' <g.rodola at gmail.com> wrote:
> >
> > The implementation is pretty straightforward:
> >
> > def here(concat=None):
> > """Return the absolute path of the parent directory where the
> > script is defined.
> > """
> > here = os.path.abspath(os.path.dirname(__file__))
> > if concat is not None:
> > here = os.path.abspath(os.path.join(here, concat))
> > return here
>
> So if I do from os.path import here and get the above function what
> happens when I call it in another module?
>
Ouch! You're right, I naively didn't take that into account. =)
I guess there are ways to inspect the caller's module name but I'm not
gonna push for that.
Sorry for the noise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140219/f37777ea/attachment-0001.html>
More information about the Python-ideas
mailing list