I have several scripts that take as input a directory name, and my program creates files in those directories. Sometimes I want to take the basename of a directory given to the
Use os.path.join() to build up paths. For example:
>>> import os.path >>> path = 'foo/bar' >>> os.path.join(path, 'filename') 'foo/bar/filename' >>> path = 'foo/bar/' >>> os.path.join(path, 'filename') 'foo/bar/filename'