June 2019
Beginner to intermediate
770 pages
19h 24m
English
We'll define an option that has an argument with the long and optional short name. We'll provide an action that stores the value provided with the argument. We can also provide a type conversion, in case we want float or int values instead of a string. Let's set this up using the following code:
parser.add_argument( "-b", "--bet", action="store", default="Flat", choices=["Flat", "Martingale", "OneThreeTwoSix"], dest='betting_rule') parser.add_argument( "-s", "--stake", action="store", default=50, type=int)
The first example will define two versions of the command-line syntax, both long and short version. When parsing the command-line argument values, a string value must follow the option, and it must be from the ...
Read now
Unlock full access