O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

site

The site module is automatically imported when the interpreter starts and is used to perform sitewide initialization of packages and to set the default Unicode encoding. The module works by first creating a list of up to four directory names created from the values of sys.prefix and sys.exec_prefix. On Windows, the list of directories is as follows:

[ sys.prefix,
   sys.exec_prefix ]

On UNIX, the directories are as follows:

[ sys.prefix + '  lib/pythonvers/site-packages ,
  sys.prefix + '  lib/site-python ,
  sys.exec_prefix + '  lib/pythonvers/site-packages ,
  sys.exec_prefix + '  lib/site-python  ]

For each directory in the list, a check is made to see whether the directory exists. If so, it’s added to the sys.path variable. Next, a check is made to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required