There is no point in doing a boolean choice as the arg would exist for true, otherwise would be false if there is no arg
And yes dont use optparse anymore, only argparse
parser.add_argument('-c','--clean', action='store_true', help='Remove all .pyc files and __pycache__ directories') args = vars(parser.parse_args()) if args[‘clean‘]: passargs.clean is true if given -c option and is false if not given any arg or no -c arg at least
And yes dont use optparse anymore, only argparse
Recommended Tutorials: