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
You should use os.path.join() to add paths together.
use
os.path.dirname(os.path.join(output_dir,''))
to extract dirname, while adding a trailing slash if it was omitted.