Python: optparse vs. argparse
Be careful when you switch from optparse.OptionParser to argparse.ArgumentParser as they use different defaults for action="store_true"
and action="store_false"
:
The former initializes the value to None
while the later one to the inverse of the desired action, that is to False
if action="store_true"
is used and vis-versa.
Even more alternatives for parsing command line arguments:
PS: Our former college “Janek” would call argparse
an “atrocity” anyway and you should stay with optparse
.
Written on July 9, 2020