search path setting is shell variable used by python to import modules by setting it once in your operating systemits value is available every time python program is run shell variables can also be set by programs to serve as inputs to other programs in an applicationbecause their values are normally inherited by spawned programsthey can be used as simple form of interprocess communication fetching shell variables in pythonthe surrounding shell environment becomes simple preset objectnot special syntax indexing os environ by the desired shell variable' name string ( os environ['user']is the moral equivalent of adding dollar sign before variable name in most unix shells ( $user)using surrounding percent signs on dos (%user%)and calling getenv("user"in program let' start up an interactive session to experiment (run in python on windows laptop)import os os environ keys(keysview(list(os environ keys()['tmp''computername''userdomain''psmodulepath''commonprogramfiles'many more deleted 'number_of_processors''processor_level''userprofile''os''public''qtjava'os environ['temp'' :\\users\\mark\\appdata\\local\\tempherethe keys method returns an iterable of assigned variablesand indexing fetches the value of the shell variable temp on windows this works the same way on linuxbut other variables are generally preset when python starts up since we know about pythonpathlet' peek at its setting within python to verify its content (as wrote thismine was set to the root of the book examples tree for this fourth editionas well as temporary development location)os environ['pythonpath'' :\\pp thed\\examples; :\\users\\mark\\tempfor srcdir in os environ['pythonpath'split(os pathsep)print(srcdirc:\pp thed\examples :\users\mark\temp import sys sys path[: [''' :\\pp thed\\examples'' :\\users\\mark\\temp'pythonpath is string of directory paths separated by whatever character is used to separate items in such paths on your platform ( on dos/windowson unix and linuxto split it into its componentswe pass to the split string method an script execution context