import argparse parser = argparse.ArgumentParser(description='desription') parser.add_argument('arguments', nargs='+', help='some description about the arguments') args = parser.perse_args() # your codeThe plus sign in nargs will produce an error if there is no argument. It requires at least one. It will take all positional arguments and it will put them to a list
args.arguments
.It depends on you to check if there is one argument or more. And if the numbers are positive or both integers or floats. The arguments are strings.
You can use add_argument type option (
type=int
) but I don't know how to check for two types according to how many arguments are provided. The date parsing is on you too. However, you can write a function do check all of this: the number of the arguments and if they are two the type and if they are positive.Quote:type= can take any callable that takes a single string argument and returns the converted value
So you can write your own validator function and use it as type argument.
gmpy2 module can do math with arbitrary precision. And it's doing it fast.