I am trying to use argparse to parse command line arguments. Here is my code:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import argparse
def create_parser():
parser = argparse.ArgumentParser()
parser.add_argument('--allow_ips', nargs='*')
return parser
if __name__ == '__main__':
parser = create_parser()
namespace = parser.parse_args()
When the script is executed like this, argparse complains about unrecognized arguments.
./prog.py --allow_ips=192.168.0.10 192.168.0.11 192.168.0.12
But when the script is executed like this, argparse is satisfied.
./prog.py --allow_ips 192.168.0.10 192.168.0.11 192.168.0.12
How should I change my code so '=' can be used in the argument list?
single command-line argument,)ipaddress.IPv4Address