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
Manually building up paths is a bad idea for portability; it will break on Windows. You should use os.path.sep.
As for your first question, using os.path.join is the right idea.