import argparse
parser = argparse.ArgumentParser(description="List or update! That is the question!")
group = parser.add_mutually_exclusive_group()
group.add_argument('-l', '--list', dest="update", action='store_false')
group.add_argument('-u', '--update', dest="update", action='store_true')
args = parser.parse_args()
print args
If the user does not specify any optional arguments I want update=False
.
[Edit]: I changed my question to not be so general, it was confusing. Sorry.