I'm learning the argparse module, and I wrote code as follows:
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)
I saved it as argparse.py, but when I run it in cmd, it shows:
AttributeError: 'module' object has no attribute 'ArgumentParser'
what's the problem? Thank you for your help.
importyou are loading yourself, rather than the standard library module.