mercredi 15 juin 2016

ArgumentParser for numpy array


Is there a way to add an argument to ArgumentParser for an np.array instead of a list? I know I can do something like this

import argparse
parser = argparse.ArgumentParser(prog='PROG')
parser.add_argument('-foo', action='store', type=int, nargs='+')
args = parser.parse_args(['-foo', '1', '2'])
args.foo = np.array(args.foo)

But I would like to specify the complete description of the arguments before parsing.

Is there a way to do this?


Aucun commentaire:

Enregistrer un commentaire