#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    Problem finding "abspath" of files


    Elementery question.
    I have been using
    import os
    os.path.abspath("file name.txt") in order to be able to open files.
    This gives me the wrong path because it leads to where the .py scripts reside. Using this abspath I am unable to open the files-for good reasons. I tried to change the directory to where the file is located-but that did not help.

    (Python 3.2 on Mac OS X 10.6.8)

    Please advise.
    Thanks
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,904
    Rep Power
    481
    If you know where a file is you should be able to (attempt to) open it. Have you yet tried

    os.chdir('newpath')

    Comments on this post

    • williamsjm5 agrees
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo