annotate example/argparse_undefined.py @ 139:30abbd61ea5e

example
author Jeff Hammel <k0scist@gmail.com>
date Tue, 04 Nov 2014 15:56:54 -0800
parents
children c6aea14a3e2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
139
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 illustrate which options are parsed with argparse
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import argparse
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import sys
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 class UndefinedArgumentParser(argparse.ArgumentParser)
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 def main(args=sys.argv[1:]):
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 parser = UndefinedArgumentParser()
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 parser.add_argument('--foo', dest='foo',
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 help="foo")
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 if __name__ == '__main__':
30abbd61ea5e example
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 main()