1

I have the following code:

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-option', choices=['a','b','c'],type=str, default='a')
args = parser.parse_args(['-option','a'])
print(args)

resulting namespace object:

Namespace(option='a')

If I run the parse_args() without passing any argument I also get:

Namespace(option='a')

Is there a way to differentiate if the option was given by the user or it was set by the default value?

0 Answers0