def path(d): try: assert os.path.isdir(d) return d except Exception as e: raise argparse.ArgumentTypeError("Example {} cannot be located.".format(d))