I have written to following code but it feels very clunky and I was wondering if there was a pythonic way of writing the following code:
import argparse
foo = 0
bar = 1
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--foo", type=int,
help="foo")
parser.add_argument("-b", "--bar", type=int,
help="bar")
args = parser.parse_args()
if args.foo: # This is the bit that I think is clunky
foo = args.foo #
if args.bar: #
bar = args.bar #
In my code I have about 7 different arguments and having a list of if statements doesn't seem like the best method. Is there a better way of writing this section?