I think I posted this somewhere else in this thread, or the previous thread.
argparse can handle negative numbers, but only of one of the built-in primitive types. See example below: ``` import re, argparse class meters(float): def __new__(cls, x): return super().__new__(cls, float(re.sub(r'm','',x))) parser = argparse.ArgumentParser() parser.add_argument("-l", "--length", dest='length', type=meters) # _StoreAction(option_strings=['-l', '--length'], dest='length', nargs=None, const=None, default=None, type=<class '__main__.meters'>, choices=None, help=None, metavar=None) meters("12") #12.0 meters("12m") #12.0 parser.parse_args("-l -12".split()) #Namespace(length=-12.0) parser.parse_args("-l -12m".split()) #usage: [-h] [-l LENGTH] #: error: argument -l/--length: expected one argument ``` _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3DD4ABOL4D4SCBG4DBBZBUICFYSZZ24U/ Code of Conduct: http://python.org/psf/codeofconduct/