So I'm trying to teach myself how to use the python library argparse
via the tutorial here. The example is given by the following piece of code which is saved as tut.py
.
import argparse
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
const=sum, default=max,
help='sum the integers (default: find the max)')
args = parser.parse_args()
print(args.accumulate(args.integers))
In the tutorial they put a $
before every command in the command line which is due to them using Linux I think. First if I add an $
in my windows command line before any command I get the error
The "$" command was either misspelled or could not be found.
If I then run
python tut.py 1 2 3 4
I don't get an error but neither is any output displayed in the command line. What would be expected is the sum of those integers though.
How can I make the output show up in the command prompt ?