abspath does not seems to work

This is the place for queries that don't fit in any of the other categories.

abspath does not seems to work

Postby afterthought » Sat Apr 27, 2013 6:39 pm

New to Python and programing. Using Python 3.3 on OS x 10.6.8

I have been trying to get the full path of a file and "os.path.abspath("file_name") leads me to the wrong place. (The file is in a folder on the "Desktop" and abspath leads me to "Documents". Obviously when I try to open the file -using the path provided by abspath- Python says that the file doesn't exist.

What am I overlooking??
Posts: 1
Joined: Sat Apr 27, 2013 6:21 pm

Re: abspath does not seems to work

Postby stranac » Sat Apr 27, 2013 8:10 pm

os.path.abspath() won't search your computer for the file.
It just takes the current working directory and the file name, and creates an absolute path from the two.

To open that file, you'll either have to provide the full path, or change to the directory the file is in.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
Posts: 1790
Joined: Thu Feb 07, 2013 3:42 pm

Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 5 guests