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

Alex Kleider akleider at sonic.net
Sat Jul 19 04:51:02 CEST 2014


On 2014-07-18 18:46, Danny Yoo wrote:
> 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

Just what I wanted. (Don't know how I missed it.)  Thank you very much.
alex


More information about the Tutor mailing list