Reputation: 21
I have WORDS_TXT = /macintosh HD/users/[username]/Desktop/[file]/words.txt/
but when run, python says "no such file or directory", however going though finder and "go to folder" that exact pathname brings me to the file I am trying to open. I am running python 3.2 on a macbook pro with Mac OS X 10.7
thank you in advance
Upvotes: 2
Views: 10158
Reputation: 1
Try this:
WORDS_TXT = '\macintosh HD\users/[username]\Desktop/[file]\words.txt\'
Upvotes: 0
Reputation: 308528
If the filename was read from another file, there's a chance that you have an end of line character or whitespace at the end of the string. You should remove this plus the extraneous '/' at the end of the filename.
WORDS_TXT = WORDS_TXT.rstrip(' \r\n/')
Upvotes: 1
Reputation: 386372
Rest assured, python has no limitation in this regard. About the only two possibilities are:
Upvotes: 0
Reputation: 1268
WORDS_TXT = '/macintosh HD/users/[username]/Desktop/[file]/words.txt/'
WORDS_TXT.rstrip('/')
Upvotes: 1