Passing a tuple as command line argument [duplicate]
问题 This question already has answers here : converting string to tuple (3 answers) Closed 4 years ago . My requirement is to pass a tuple as command line argument like --data (1,2,3,4) I tried to use the argparse module, but if I pass like this it is receiving as the string '(1,2,3,4)' . I tried by giving type=tuple for argparse.add_argument , but is of no use here. Do I have to add a new type class and pass that to type argument of add_argument ? Update I tried the ast.literal_eval based on