Python argument parser list of list or tuple of tuples

You can add your own type. This also allows for additional validations, for example:

def coords(s):
    try:
        x, y, z = map(int, s.split(','))
        return x, y, z
    except:
        raise argparse.ArgumentTypeError("Coordinates must be x,y,z")


parser.add_argument('--cord', help="Coordinate", dest="cord", type=coords, nargs=3)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)