On Fri, Jul 18, 2014 at 6:33 PM, Alex Kleider <aklei...@sonic.net> wrote:
> Is there a function that can return the full path name when provided with > something along the lines of > "../../myfile"? > The OS module is great at this. Here's an example: import os MYFILE= '../../myfile' print "MYFILE", MYFILE print "abspath", os.path.abspath(MYFILE) And, here is the output: prompt> python example01.py MYFILE ../../myfile abspath /Users/glenjarvis/Desktop/test/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. > You can also glean just the current working directory: import os print "pwd", os.getcwd() And it's output: prompt> python example02.py pwd /Users/glenjarvis/Desktop/test/x/y Cheers, Glen -- "You grab mindshare by being there." -- Alex Martelli Bay Area Python Interest Group Talk 24-Oct, 2013
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor