import os import errno import sys def main(args): for dirname in args: try: os.makedirs(dirname) except OSError as e: if e.errno == errno.EEXIST: # It's OK if it already exists pass else: raise if __name__ == '__main__': main(sys.argv[1:]) 1 2 3 4 5 ...