os.getcwd gives me the wrong directory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xx r3negade
    New Member
    • Apr 2008
    • 39

    os.getcwd gives me the wrong directory

    Hi.
    I have a script located in /home/jBrandt/Code/python/ftest.py.
    When I print the results of os.getcwd(), however, it gives me /home/jBrandt/Code as the current working directory. I realize that I could change the cwd, but the directory name will not be the same on all computers. I've also tried os.curdir, and all it returns is a single dot (wtf?)

    Anyway, I need a tried-and-true method for getting the cwd; any help would be appreciated.
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    The dot is a Unix/Linux shortcut that means current directory. Two dots means the parent directory to the current directory. As to the other issue...is the print call in a module being run from another script that is in the folder in question? It sounds like either that's the case or there's a hidden cd/os.chdir() call.

    Comment

    Working...