Thread: sys.path

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

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    13

    sys.path


    Hi,
    When I use the sys.path command I get a list of paths

    Code:
    >>> sys.path
    ['', 'C:\\WINDOWS\\system32\\python23.zip', 'C:\\Python23', 'C:\\Python23\\DLLs', 'C:\\Python23\\lib', 'C:\\Python23\\lib\\plat-win', 'C:\\Python23\\lib\\lib-tk', 'C:\\Python23\\Lib\\site-packages\\pythonwin', 'C:\\Python23\\Lib\\site-packages\\win32', 'C:\\Python23\\Lib\\site-packages\\win32\\lib', 'C:\\Python23\\lib\\site-packages']
    why is that so?

    Rgds,
    Subha
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    From the docs for the sys module:

    path
    A list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default.
    As initialized upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first. Notice that the script directory is inserted before the entries inserted as a result of PYTHONPATH.

    A program is free to modify this list for its own purposes.

    Changed in version 2.3: Unicode strings are no longer ignored..
    sys.path contains a list of directories because Python can search for module files in multiple locations.

    Dave
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    13
    Thanks Dave, wasn't aware of this concept!

    Subha

IMN logo majestic logo threadwatch logo seochat tools logo