3

today, I checked how sys.path got implemented by python. i found it points to sys.pi file(python 2.7.8 in windows). see code

argv = []
__stdout__ = file(__file__)
__name__ = 'sysoverride'
__stderr__ = file(__file__)
dllhandle = 0
exitfunc = None
stdin = file(__file__)
modules = {}
last_type = None
stderr = file(__file__)
path = []
last_value = None
hexversion = 17105408

my question is how python can print out a list of python paths with path=[] statement. it is really confused me. Thanks

cppython
  • 1,159
  • 3
  • 17
  • 29

1 Answers1

2

According to the doc's

sys.path is a list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default.

In addition to that , there is a site module wich is automatically imported during initialization wich appends site-specific paths and builtins to the module search path .

Alexander
  • 11,808
  • 5
  • 55
  • 72