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)
How to create argument of type "list of pairs" with argparse?