def dir_type(arg):
	"""An argparse type representing a valid directory."""
	if not os.path.isdir(arg):
		raise argparse.ArgumentTypeError("{0} is not a valid directory".format(repr(arg)))
	return arg
An argparse type representing a valid directory.