Skip to content Skip to sidebar Skip to footer

Python Argparse Storing Arguments As Lists Rather Than Ints. Confusing Or Correct?

I am using two test scripts to teach myself how to use argparse and subprocess libraries in Python. I am confused about the type=int value in add_argument(). calculator.py: import

Solution 1:

Remove the nargs=1 part. From: https://docs.python.org/3/library/argparse.html#nargs

Note that nargs=1 produces a list of one item. This is different from the default, in which the item is produced by itself.

Post a Comment for "Python Argparse Storing Arguments As Lists Rather Than Ints. Confusing Or Correct?"