#!/usr/bin/python3 import argparse as ap par = ap.ArgumentParser() par.add_argument('-a', type=float) cases = "1 -1 1.0 -1.0 1. -1. " cases += "1e2 -1e2 " cases += "1e+2 -1e+2 " cases += "1e-2 -1e-2 " cases += "1E2 -1E2 " cases += "1E+2 -1E+2 " cases += "1E-2 -1E-2 " cases += "1.0e2 -1.0e2 " cases += "1.0e+2 -1.0e+2 " cases += "1.0e-2 -1.0e-2 " cases += "1.0E2 -1.0E2 " cases += "1.0E+2 -1.0E+2 " cases += "1.0E-2 -1.0E-2 " cases += "1.e2 -1.e2 " cases += "1.e+2 -1.e+2 " cases += "1.e-2 -1.e-2 " cases += "1.E2 -1.E2 " cases += "1.E+2 -1.E+2 " cases += "1.E-2 -1.E-2" ntests = len(cases.split()) print (ntests) for i, c in enumerate(cases.split()): print (i, c) n = float(c) cc = "-a " + c args = par.parse_args(cc.split()) if n != args.a: raise ValueError