def main(): usage = '%prog path [path2] [path3] [pathN]\n\n' + __doc__.strip() parser = OptionParser(usage=usage, option_list=( make_option('-v', '--verbose', default=False, action='store_true'), )) options, args = parser.parse_args() if len(args) == 0: parser.error('No paths given.') output = sys.stdout if options.verbose else None for index, path in enumerate(args): path = path.replace('.', os.path.sep) if output and index > 0: output.write('\n') try: pydir(path, output=output) except BaseException as exc: print ('Couldn\'t create %s: %s' % (path, exc,))