sys.path vs os.environ['POST']

Gerhard Häring gh at ghaering.de
Wed May 21 03:53:24 EDT 2003


Achim Domma wrote:
> [...] I would have expected that sys.path and os.environ['PATH'] are the same
> thing, but it seems not! Can somebody explain the differnce to me?

sys.path are the directories Python searches for modules in when you try 
to import one. To see the Python import mechanism at work, you can start 
Python with "python -v" and then for example "import smtplib" at the 
interactive prompt.

os.environ['PATH'] refers to the PATH environment variable, which is a 
list of directories the operating system tries to find an executable in 
if you try to start an application without an absolute or relative path, 
i. e. something like "notepad" or "ls".

-- Gerhard





More information about the Python-list mailing list