arguments - Python - check if arg from arparse was chosen -


i check if argument argsparse chosen, if not choose random value variable.

here example:

parser.add_argument('--tempo', default=120, type=int, help='tempo of track') 

and 1 way example:

args = parser.parse_args()     if args.tempo==120: #my default int     tempo=random.randint(60,350) 

but way when user call program example: main.py --tempo 120, choose random value. how can check if argument chosen or not?

the problem in test. if user chose 120 give random number. think best remove default , check if empty.

parser.add_argument('--tempo', default=none, type=int, help='tempo of track') args = parser.parse_args()     if args.tempo==none: #my default int     args.tempo=randint(60,350) 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -