not the system subdirectory nested therec:\pp \systemcd :\pp epython system\whereami py my os getcwd = :\pp my sys path =[' :\\\pp \\system'' :\\pp thed\\examples'more :\pp ecd system\temp :\pp \system\temppython \whereami py my os getcwd = :\pp \system\temp my sys path =[' :\\\pp \\system'' :\\pp thed\\examples'the net effect is that filenames without directory paths in script will be mapped to the place where the command was typed (os getcwd)but imports still have access to the directory of the script being run (via the front of sys pathfinallywhen file is launched by clicking its iconthe cwd is just the directory that contains the clicked file the following outputfor exampleappears in new dos console box when whereami py is double-clicked in windows explorermy os getcwd = :\pp \system my sys path =[' :\\\pp \\system'more in this caseboth the cwd used for filenames and the first import search directory are the directory containing the script file this all usually works out just as you expectbut there are two pitfalls to avoidfilenames might need to include complete directory paths if scripts cannot be sure from where they will be run command-line scripts cannot always rely on the cwd to gain import visibility to files that are not in their own directoriesinsteaduse pythonpath settings and package import paths to access modules in other directories for examplescripts in this bookregardless of how they are runcan always import other files in their own home directories without package path imports (import file here)but must go through the pp package root to find files anywhere else in the examples tree (from pp dir dir import filethere)even if they are run from the directory containing the desired external module as usual for modulesthe pp \dir \dir directory name could also be added to pythonpath to make files there visible everywhere without package path imports (though adding more directories to python path increases the likelihood of name clashesin either casethoughimports are always resolved to the script' home directory or other python search path settingsnot to the cwd current working directory