[Tutor] how to expand "../../myfile"

Danny Yoo dyoo at hashcollision.org
Sat Jul 19 03:46:18 CEST 2014


On Fri, Jul 18, 2014 at 6:33 PM, Alex Kleider <akleider at sonic.net> wrote:
> Is there a function that can return the full path name when provided with
> something along the lines of
> "../../myfile"?
>
> Just to be able to glean the current working directory would suffice. (I
> could use a shell command if I had to but was hoping it could be done all
> within Python.

os.path.abspath() should be able to do it.  See:

    https://docs.python.org/2/library/os.path.html#os.path.abspath

    http://www.diveintopython.net/functional_programming/finding_the_path.html


More information about the Tutor mailing list