Boolean argument for script

You can either use the action with store_true|store_false, or you can use an int and let implicit casting check a boolean value.

Using the action, you wouldn’t pass a --foo=true and --foo=false argument, you would simply include it if it was to be set to true.

python myProgram.py --foo

In fact I think what you may want is

parser.add_argument('-b', action='store_true', default=False)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)