Skip to content

Instantly share code, notes, and snippets.

@ficapy ficapy/
Created Mar 1, 2015

What would you like to do?
import argparse
foo1 = sum
foo2 = max
def main(test=None):
parser = argparse.ArgumentParser(description="")
group = parser.add_mutually_exclusive_group()
group.add_argument("-foo1", action="append", type=int, default=[2])
group.add_argument("-foo2", nargs="+", type=int)
return foo2(parser.parse_args(test).foo2) if parser.parse_args(test).foo2 else foo1(parser.parse_args(test).foo1)
if __name__ == "__main__":
print main(test=["-foo1", "1"])
print main(test=["-foo2", "1", "2"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.