path cwd(windowspath(' :/users/al/appdata/local/programs/python/python 'path cwd(parents[ windowspath(' :/users/al/appdata/local/programs/python'path cwd(parents[ windowspath(' :/users/al/appdata/local/programs'path cwd(parents[ windowspath(' :/users/al/appdata/local'path cwd(parents[ windowspath(' :/users/al/appdata'path cwd(parents[ windowspath(' :/users/al'path cwd(parents[ windowspath(' :/users'path cwd(parents[ windowspath(' :/'the older os path module also has similar functions for getting the different parts of path written in string value calling os path dirname(pathwill return string of everything that comes before the last slash in the path argument calling os path basename(pathwill return string of everything that comes after the last slash in the path argument the directory (or dirname and base name of path are outlined in figure - :\windows\system \calc exe dir name base name figure - the base name follows the last slash in path and is the same as the filename the dir name is everything before the last slash for exampleenter the following into the interactive shellcalcfilepath ' :\\windows\\system \\calc exeos path basename(calcfilepath'calc exeos path dirname(calcfilepath' :\\windows\\system if you need path' dir name and base name togetheryou can just call os path split(to get tuple value with these two stringslike socalcfilepath ' :\\windows\\system \\calc exeos path split(calcfilepath(' :\\windows\\system ''calc exe'reading and writing files