Getting working directory of a module

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psbasha
    Contributor
    • Feb 2007
    • 440

    #1

    Getting working directory of a module

    Hi ,

    I have a main module in particular path say "C:\\Sample\\Te st\\main.py",an d other modules are also located in the same location.I would like to find the path of the current working directory.

    Is there any method/global function available for accessing this information?.

    Thanks
    PSB

    I/P :

    "C:\\Sample\\Te st\\main.py" -- Working directory

    O/P :
    "C:\\Sample\\Te st" -- Required working directory path
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by psbasha
    Hi ,

    I have a main module in particular path say "C:\\Sample\\Te st\\main.py",an d other modules are also located in the same location.I would like to find the path of the current working directory.

    Is there any method/global function available for accessing this information?.

    Thanks
    PSB

    I/P :

    "C:\\Sample\\Te st\\main.py" -- Working directory

    O/P :
    "C:\\Sample\\Te st" -- Required working directory path
    The current working directory is set by the command that starts python [not by the path of the module that is started].

    Code:
    import os
    print os.getcwd()

    Comment

    Working...