Can argparse in python 2.7 be told to require a minimum of TWO arguments?
问题 My application is a specialized file comparison utility and obviously it does not make sense to compare only one file, so nargs='+' is not quite appropriate. nargs=N only excepts a maximum of N arguments, but I need to accept an infinite number of arguments as long as there are at least two of them. 回答1: Short answer is you can't do that because nargs doesn't support something like '2+'. Long answer is you can workaround that using something like this: parser = argparse.ArgumentParser(usage='