Argparse does not attempt to cover all possible input formats. You can always get sizes as a string and parse them with a few lines of code:
import argparse parser = argparse.ArgumentParser() parser.add_argument('--sizes', nargs='+') args = parser.parse_args() try: sizes = [tuple(map(int, s.split(',', maxsplit=1))) for s in args.sizes] except Exception: print('sizes cannot be parsed') print(sizes)
"Special cases are not complex enough to break the rules."
source share