<p>What's the <strong>easiest</strong>, <strong>tersest</strong>, and most <strong>flexible</strong> method or library for parsing Python command line arguments?</p>

[{'answer_id': 20065, 'author': 'Corey', 'author_id': 1595, 'author_profile': 'https://Stackoverflow.com/users/1595', 'pm_score': 4, 'selected': False, 'text': '<p>Use <code>optparse</code> which comes with the standard library. For example:</p>\n\n<pre><code>#!/usr/bin/env python\nimport optparse\n\ndef main():\n  p = optparse.OptionParser()\n  p.add_option(\'--person\', \'-p\', default="world")\n  options, arguments = p.parse_args()\n  print \'Hello %s\' % options.person\n\nif __name__ == \'__main__\':\n  main()\n</code></pre>\n\n<p>Source: <a href="http://www.ibm.com/developerworks/aix/library/au-pythocli/" rel="nofollow noreferrer">Using Python to create UNIX command line tools</a></p>\n\n<p>However as of Python 2.7 optparse is deprecated, see: <a href="https://stackoverflow.com/q/3217673/55075">Why use argparse rather than optparse?</a></p>\n'}, {'answer_id': 20069, 'author': 'fulmicoton', 'author_id': 446497, 'author_profile': 'https://Stackoverflow.com/users/446497', 'pm_score': 4, 'selected': False, 'text': '<p>Pretty much everybody is using <a href="http://python.active-venture.com/lib/module-getopt.html" rel="nofollow noreferrer">getopt</a></p>\n\n<p>Here is the example code for the doc :</p>\n\n<pre><code>import getopt, sys\n\ndef main():\n    try:\n        opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])\n    except getopt.GetoptError:\n        # print help information and exit:\n        usage()\n        sys.exit(2)\n    output = None\n    verbose = False\n    for o, a in opts:\n        if o == "-v":\n            verbose = True\n        if o in ("-h", "--help"):\n            usage()\n            sys.exit()\n        if o in ("-o", "--output"):\n            output = a\n</code></pre>\n\n<p>So in a word, here is how it works.</p>\n\n<p>You\'ve got two types of options. Those who are receiving arguments, and those who are\njust like switches.</p>\n\n<p><code>sys.argv</code> is pretty much your <code>char** argv</code> in C. Like in C you skip the first element which is the name of your program and parse only the arguments : <code>sys.argv[1:]</code></p>\n\n<p><code>Getopt.getopt</code> will parse it according to the rule you give in argument.</p>\n\n<p><code>"ho:v"</code> here describes the short arguments : <code>-ONELETTER</code>. The <code>:</code> means that <code>-o</code> accepts one argument.</p>\n\n<p>Finally <code>["help", "output="]</code> describes long arguments ( <code>--MORETHANONELETTER</code> ).\nThe <code>=</code> after output once again means that output accepts one arguments.</p>\n\n<p>The result is a list of couple (option,argument)</p>\n\n<p>If an option doesn\'t accept any argument (like <code>--help</code> here) the <code>arg</code> part is an empty string.\nYou then usually want to loop on this list and test the option name as in the example.</p>\n\n<p>I hope this helped you.</p>\n'}, {'answer_id': 20169, 'author': 'Shadow2531', 'author_id': 1697, 'author_profile': 'https://Stackoverflow.com/users/1697', 'pm_score': 3, 'selected': False, 'text': '<p>Just in case you might need to, this may help if you need to <strong>grab</strong> unicode arguments on Win32 (2K, XP etc):</p>\n\n<pre><code>\nfrom ctypes import *\n\ndef wmain(argc, argv):\n    print argc\n    for i in argv:\n        print i\n    return 0\n\ndef startup():\n    size = c_int()\n    ptr = windll.shell32.CommandLineToArgvW(windll.kernel32.GetCommandLineW(), byref(size))\n    ref = c_wchar_p * size.value\n    raw = ref.from_address(ptr)\n    args = [arg for arg in raw]\n    windll.kernel32.LocalFree(ptr)\n    exit(wmain(len(args), args))\nstartup()\n</code></pre>\n'}, {'answer_id': 20222, 'author': 'Chris Conway', 'author_id': 1412, 'author_profile': 'https://Stackoverflow.com/users/1412', 'pm_score': 2, 'selected': False, 'text': '<p>I prefer optparse to getopt. It\'s very declarative: you tell it the names of the options and the effects they should have (e.g., setting a boolean field), and it hands you back a dictionary populated according to your specifications.</p>\n\n<p><a href="http://docs.python.org/lib/module-optparse.html" rel="nofollow noreferrer">http://docs.python.org/lib/module-optparse.html</a></p>\n'}, {'answer_id': 26910, 'author': 'Thomas Vander Stichele', 'author_id': 2900, 'author_profile': 'https://Stackoverflow.com/users/2900', 'pm_score': 9, 'selected': True, 'text': '<p><strong>This answer suggests <code>optparse</code> which is appropriate for older Python versions. For Python 2.7 and above, <code>argparse</code> replaces <code>optparse</code>. See <a href="https://stackoverflow.com/questions/3217673/why-use-argparse-rather-than-optparse">this answer</a> for more information.</strong></p>\n\n<p>As other people pointed out, you are better off going with optparse over getopt.  getopt is pretty much a one-to-one mapping of the standard getopt(3) C library functions, and not very easy to use.</p>\n\n<p>optparse, while being a bit more verbose, is much better structured and simpler to extend later on.</p>\n\n<p>Here\'s a typical line to add an option to your parser:</p>\n\n<pre><code>parser.add_option(\'-q\', \'--query\',\n            action="store", dest="query",\n            help="query string", default="spam")\n</code></pre>\n\n<p>It pretty much speaks for itself; at processing time, it will accept -q or --query as options, store the argument in an attribute called query and has a default value if you don\'t specify it.  It is also self-documenting in that you declare the help argument (which will be used when run with -h/--help) right there with the option.</p>\n\n<p>Usually you parse your arguments with:</p>\n\n<pre><code>options, args = parser.parse_args()\n</code></pre>\n\n<p>This will, by default, parse the standard arguments passed to the script (sys.argv[1:])</p>\n\n<p>options.query will then be set to the value you passed to the script.</p>\n\n<p>You create a parser simply by doing</p>\n\n<pre><code>parser = optparse.OptionParser()\n</code></pre>\n\n<p>These are all the basics you need.  Here\'s a complete Python script that shows this:</p>\n\n<pre><code>import optparse\n\nparser = optparse.OptionParser()\n\nparser.add_option(\'-q\', \'--query\',\n    action="store", dest="query",\n    help="query string", default="spam")\n\noptions, args = parser.parse_args()\n\nprint \'Query string:\', options.query\n</code></pre>\n\n<p>5 lines of python that show you the basics.</p>\n\n<p>Save it in sample.py, and run it once with</p>\n\n<pre><code>python sample.py\n</code></pre>\n\n<p>and once with</p>\n\n<pre><code>python sample.py --query myquery\n</code></pre>\n\n<p>Beyond that, you will find that optparse is very easy to extend.\nIn one of my projects, I created a Command class which allows you to nest subcommands in a command tree easily.  It uses optparse heavily to chain commands together.  It\'s not something I can easily explain in a few lines, but feel free to <a href="https://thomas.apestaart.org/moap/trac/browser/trunk/moap/extern/command/command.py" rel="noreferrer">browse around in my repository</a> for the main class, as well as <a href="https://thomas.apestaart.org/moap/trac/browser/trunk/moap/command/doap.py" rel="noreferrer">a class that uses it and the option parser</a></p>\n'}, {'answer_id': 30973, 'author': 'Peter Hoffmann', 'author_id': 720, 'author_profile': 'https://Stackoverflow.com/users/720', 'pm_score': 2, 'selected': False, 'text': '<p>I think the best way for larger projects is optparse, but if you are looking for an easy way, maybe <a href="http://werkzeug.pocoo.org/documentation/script" rel="nofollow noreferrer">http://werkzeug.pocoo.org/documentation/script</a> is something for you.</p>\n\n<pre><code>from werkzeug import script\n\n# actions go here\ndef action_foo(name=""):\n    """action foo does foo"""\n    pass\n\ndef action_bar(id=0, title="default title"):\n    """action bar does bar"""\n    pass\n\nif __name__ == \'__main__\':\n    script.run()\n</code></pre>\n\n<p>So basically every function action_* is exposed to the command line and a nice\nhelp message is generated for free. </p>\n\n<pre><code>python foo.py \nusage: foo.py &lt;action&gt; [&lt;options&gt;]\n       foo.py --help\n\nactions:\n  bar:\n    action bar does bar\n\n    --id                          integer   0\n    --title                       string    default title\n\n  foo:\n    action foo does foo\n\n    --name                        string\n</code></pre>\n'}, {'answer_id': 979871, 'author': 'Silfheed', 'author_id': 28421, 'author_profile': 'https://Stackoverflow.com/users/28421', 'pm_score': 5, 'selected': False, 'text': '<p>The new hip way is <code>argparse</code> for <a href="https://stackoverflow.com/questions/1009860/how-to-read-process-command-line-arguments/1050472#1050472">these</a> reasons.  argparse > optparse > getopt</p>\n\n<p><strong>update:</strong> As of py2.7 <a href="http://docs.python.org/library/argparse.html" rel="nofollow noreferrer">argparse</a> is part of the standard library and <a href="http://docs.python.org/library/optparse.html" rel="nofollow noreferrer">optparse</a> is deprecated.</p>\n'}, {'answer_id': 11271779, 'author': 'stalk', 'author_id': 821594, 'author_profile': 'https://Stackoverflow.com/users/821594', 'pm_score': 1, 'selected': False, 'text': '<p><a href="https://github.com/muromec/consoleargs" rel="nofollow">consoleargs</a> deserves to be mentioned here. It is very easy to use. Check it out:</p>\n\n<pre><code>from consoleargs import command\n\n@command\ndef main(url, name=None):\n  """\n  :param url: Remote URL \n  :param name: File name\n  """\n  print """Downloading url \'%r\' into file \'%r\'""" % (url, name)\n\nif __name__ == \'__main__\':\n  main()\n</code></pre>\n\n<p>Now in console:</p>\n\n<pre><code>% python demo.py --help\nUsage: demo.py URL [OPTIONS]\n\nURL:    Remote URL \n\nOptions:\n    --name -n   File name\n\n% python demo.py http://www.google.com/\nDownloading url \'\'http://www.google.com/\'\' into file \'None\'\n\n% python demo.py http://www.google.com/ --name=index.html\nDownloading url \'\'http://www.google.com/\'\' into file \'\'index.html\'\'\n</code></pre>\n'}, {'answer_id': 16377263, 'author': 'ndemou', 'author_id': 1011025, 'author_profile': 'https://Stackoverflow.com/users/1011025', 'pm_score': 6, 'selected': False, 'text': '<h2>Using docopt</h2>\n\n<p>Since 2012 there is a very easy, powerful and really <em>cool</em> module for argument parsing called <a href="https://github.com/docopt/docopt" rel="noreferrer">docopt</a>. Here is an example taken from its documentation: </p>\n\n<pre><code>"""Naval Fate.\n\nUsage:\n  naval_fate.py ship new &lt;name&gt;...\n  naval_fate.py ship &lt;name&gt; move &lt;x&gt; &lt;y&gt; [--speed=&lt;kn&gt;]\n  naval_fate.py ship shoot &lt;x&gt; &lt;y&gt;\n  naval_fate.py mine (set|remove) &lt;x&gt; &lt;y&gt; [--moored | --drifting]\n  naval_fate.py (-h | --help)\n  naval_fate.py --version\n\nOptions:\n  -h --help     Show this screen.\n  --version     Show version.\n  --speed=&lt;kn&gt;  Speed in knots [default: 10].\n  --moored      Moored (anchored) mine.\n  --drifting    Drifting mine.\n\n"""\nfrom docopt import docopt\n\n\nif __name__ == \'__main__\':\n    arguments = docopt(__doc__, version=\'Naval Fate 2.0\')\n    print(arguments)\n</code></pre>\n\n<p>So this is it: 2 lines of code plus your doc string which <em>is</em> essential and you get your arguments parsed and available in your arguments object.</p>\n\n<h2>Using python-fire</h2>\n\n<p>Since 2017 there\'s another cool module called <a href="https://github.com/google/python-fire" rel="noreferrer">python-fire</a>. It can generate a CLI interface for your code with you doing <em>zero</em> argument parsing. Here\'s a simple example from the documentation (this small program exposes the function <code>double</code> to the command line):</p>\n\n<pre><code>import fire\n\nclass Calculator(object):\n\n  def double(self, number):\n    return 2 * number\n\nif __name__ == \'__main__\':\n  fire.Fire(Calculator)\n</code></pre>\n\n<p>From the command line, you can run:</p>\n\n<pre><code>&gt; calculator.py double 10\n20\n&gt; calculator.py double --number=15\n30\n</code></pre>\n'}, {'answer_id': 27069329, 'author': 'suda', 'author_id': 83055, 'author_profile': 'https://Stackoverflow.com/users/83055', 'pm_score': 5, 'selected': False, 'text': '<p>I prefer <a href="http://click.pocoo.org/" rel="noreferrer">Click</a>. It abstracts managing options and allows "(...) creating beautiful command line interfaces in a composable way with as little code as necessary".</p>\n\n<p>Here\'s example usage:</p>\n\n<pre><code>import click\n\n@click.command()\n@click.option(\'--count\', default=1, help=\'Number of greetings.\')\n@click.option(\'--name\', prompt=\'Your name\',\n              help=\'The person to greet.\')\ndef hello(count, name):\n    """Simple program that greets NAME for a total of COUNT times."""\n    for x in range(count):\n        click.echo(\'Hello %s!\' % name)\n\nif __name__ == \'__main__\':\n    hello()\n</code></pre>\n\n<p>It also automatically generates nicely formatted help pages:</p>\n\n<pre><code>$ python hello.py --help\nUsage: hello.py [OPTIONS]\n\n  Simple program that greets NAME for a total of COUNT times.\n\nOptions:\n  --count INTEGER  Number of greetings.\n  --name TEXT      The person to greet.\n  --help           Show this message and exit.\n</code></pre>\n'}, {'answer_id': 30493366, 'author': 'Andrzej Pronobis', 'author_id': 1576602, 'author_profile': 'https://Stackoverflow.com/users/1576602', 'pm_score': 9, 'selected': False, 'text': '<p><a href="https://docs.python.org/library/argparse.html" rel="noreferrer"><code>argparse</code></a> is the way to go. Here is a short summary of how to use it:</p>\n\n<p><strong>1) Initialize</strong></p>\n\n<pre><code>import argparse\n\n# Instantiate the parser\nparser = argparse.ArgumentParser(description=\'Optional app description\')\n</code></pre>\n\n<p><strong>2) Add Arguments</strong></p>\n\n<pre><code># Required positional argument\nparser.add_argument(\'pos_arg\', type=int,\n                    help=\'A required integer positional argument\')\n\n# Optional positional argument\nparser.add_argument(\'opt_pos_arg\', type=int, nargs=\'?\',\n                    help=\'An optional integer positional argument\')\n\n# Optional argument\nparser.add_argument(\'--opt_arg\', type=int,\n                    help=\'An optional integer argument\')\n\n# Switch\nparser.add_argument(\'--switch\', action=\'store_true\',\n                    help=\'A boolean switch\')\n</code></pre>\n\n<p><strong>3) Parse</strong></p>\n\n<pre><code>args = parser.parse_args()\n</code></pre>\n\n<p><strong>4) Access</strong></p>\n\n<pre><code>print("Argument values:")\nprint(args.pos_arg)\nprint(args.opt_pos_arg)\nprint(args.opt_arg)\nprint(args.switch)\n</code></pre>\n\n<p><strong>5) Check Values</strong></p>\n\n<pre><code>if args.pos_arg &gt; 10:\n    parser.error("pos_arg cannot be larger than 10")\n</code></pre>\n\n<h2>Usage</h2>\n\n<p><strong>Correct use:</strong></p>\n\n<pre><code>$ ./app 1 2 --opt_arg 3 --switch\n\nArgument values:\n1\n2\n3\nTrue\n</code></pre>\n\n<p><strong>Incorrect arguments:</strong></p>\n\n<pre><code>$ ./app foo 2 --opt_arg 3 --switch\nusage: convert [-h] [--opt_arg OPT_ARG] [--switch] pos_arg [opt_pos_arg]\napp: error: argument pos_arg: invalid int value: \'foo\'\n\n$ ./app 11 2 --opt_arg 3\nArgument values:\n11\n2\n3\nFalse\nusage: app [-h] [--opt_arg OPT_ARG] [--switch] pos_arg [opt_pos_arg]\nconvert: error: pos_arg cannot be larger than 10\n</code></pre>\n\n<p><strong>Full help:</strong></p>\n\n<pre><code>$ ./app -h\n\nusage: app [-h] [--opt_arg OPT_ARG] [--switch] pos_arg [opt_pos_arg]\n\nOptional app description\n\npositional arguments:\n  pos_arg            A required integer positional argument\n  opt_pos_arg        An optional integer positional argument\n\noptional arguments:\n  -h, --help         show this help message and exit\n  --opt_arg OPT_ARG  An optional integer argument\n  --switch           A boolean switch\n</code></pre>\n'}, {'answer_id': 36516929, 'author': 'erco', 'author_id': 836131, 'author_profile': 'https://Stackoverflow.com/users/836131', 'pm_score': 1, 'selected': False, 'text': '<p>Here\'s a method, not a library, which seems to work for me.</p>\n\n<p>The goals here are to be terse, each argument parsed by a single line, the args line up for readability, the code is simple and doesn\'t depend on any special modules (only os + sys), warns about missing or unknown arguments gracefully, use a simple for/range() loop, and works across python 2.x and 3.x</p>\n\n<p>Shown are two toggle flags (-d, -v), and two values controlled by arguments (-i xxx and -o xxx).</p>\n\n<pre><code>import os,sys\n\ndef HelpAndExit():\n    print("&lt;&lt;your help output goes here&gt;&gt;")\n    sys.exit(1)\n\ndef Fatal(msg):\n    sys.stderr.write("%s: %s\\n" % (os.path.basename(sys.argv[0]), msg))\n    sys.exit(1)\n\ndef NextArg(i):\n    \'\'\'Return the next command line argument (if there is one)\'\'\'\n    if ((i+1) &gt;= len(sys.argv)):\n        Fatal("\'%s\' expected an argument" % sys.argv[i])\n    return(1, sys.argv[i+1])\n\n### MAIN\nif __name__==\'__main__\':\n\n    verbose = 0\n    debug   = 0\n    infile  = "infile"\n    outfile = "outfile"\n\n    # Parse command line\n    skip = 0\n    for i in range(1, len(sys.argv)):\n        if not skip:\n            if   sys.argv[i][:2] == "-d": debug ^= 1\n            elif sys.argv[i][:2] == "-v": verbose ^= 1\n            elif sys.argv[i][:2] == "-i": (skip,infile)  = NextArg(i)\n            elif sys.argv[i][:2] == "-o": (skip,outfile) = NextArg(i)\n            elif sys.argv[i][:2] == "-h": HelpAndExit()\n            elif sys.argv[i][:1] == "-":  Fatal("\'%s\' unknown argument" % sys.argv[i])\n            else:                         Fatal("\'%s\' unexpected" % sys.argv[i])\n        else: skip = 0\n\n    print("%d,%d,%s,%s" % (debug,verbose,infile,outfile))\n</code></pre>\n\n<p>The goal of NextArg() is to return the next argument while checking for missing data, and \'skip\' skips the loop when NextArg() is used, keeping the flag parsing down to one liners.</p>\n'}, {'answer_id': 43234054, 'author': 'Simon Hibbs', 'author_id': 318488, 'author_profile': 'https://Stackoverflow.com/users/318488', 'pm_score': 4, 'selected': False, 'text': "<p><strong>Lightweight command line argument defaults</strong></p>\n\n<p>Although <code>argparse</code> is great and is the right answer for fully documented command line switches and advanced features, you can use function argument defaults to handles straightforward positional arguments very simply.</p>\n\n<pre><code>import sys\n\ndef get_args(name='default', first='a', second=2):\n    return first, int(second)\n\nfirst, second = get_args(*sys.argv)\nprint first, second\n</code></pre>\n\n<p>The 'name' argument captures the script name and is not used. Test output looks like this:</p>\n\n<pre><code>&gt; ./test.py\na 2\n&gt; ./test.py A\nA 2\n&gt; ./test.py A 20\nA 20\n</code></pre>\n\n<p>For simple scripts where I just want some default values, I find this quite sufficient. You might also want to include some type coercion in the return values or command line values will all be strings.</p>\n"}, {'answer_id': 51185393, 'author': 'QA Collective', 'author_id': 5196274, 'author_profile': 'https://Stackoverflow.com/users/5196274', 'pm_score': 3, 'selected': False, 'text': '<p>Argparse code can be longer than actual implementation code!</p>\n\n<p>That\'s a problem I find with most popular argument parsing options is that if your parameters are only modest, the code to document them becomes disproportionately large to the benefit they provide.  </p>\n\n<p>A relative new-comer to the argument parsing scene (I think) is <a href="https://micheles.github.io/plac/" rel="noreferrer">plac</a>.</p>\n\n<p>It makes some acknowledged trade-offs with argparse, but uses inline documentation and wraps simply around <code>main()</code> type function function:</p>\n\n<pre><code>def main(excel_file_path: "Path to input training file.",\n     excel_sheet_name:"Name of the excel sheet containing training data including columns \'Label\' and \'Description\'.",\n     existing_model_path: "Path to an existing model to refine."=None,\n     batch_size_start: "The smallest size of any minibatch."=10.,\n     batch_size_stop:  "The largest size of any minibatch."=250.,\n     batch_size_step:  "The step for increase in minibatch size."=1.002,\n     batch_test_steps: "Flag.  If True, show minibatch steps."=False):\n"Train a Spacy (http://spacy.io/) text classification model with gold document and label data until the model nears convergence (LOSS &lt; 0.5)."\n\n    pass # Implementation code goes here!\n\nif __name__ == \'__main__\':\n    import plac; plac.call(main)\n</code></pre>\n'}, {'answer_id': 51498731, 'author': 'Erik', 'author_id': 7384642, 'author_profile': 'https://Stackoverflow.com/users/7384642', 'pm_score': 0, 'selected': False, 'text': '<p>I extended Erco\'s approach to allow for required positional arguments and for optional arguments. These should precede the -d, -v etc. arguments.</p>\n\n<p>Positional and optional arguments can be retrieved with PosArg(i) and OptArg(i, default) respectively.\nWhen an optional argument is found the start position of searching for options (e.g. -i) is moved 1 ahead to avoid causing an \'unexpected\' fatal.</p>\n\n<pre><code>import os,sys\n\n\ndef HelpAndExit():\n    print("&lt;&lt;your help output goes here&gt;&gt;")\n    sys.exit(1)\n\ndef Fatal(msg):\n    sys.stderr.write("%s: %s\\n" % (os.path.basename(sys.argv[0]), msg))\n    sys.exit(1)\n\ndef NextArg(i):\n    \'\'\'Return the next command line argument (if there is one)\'\'\'\n    if ((i+1) &gt;= len(sys.argv)):\n        Fatal("\'%s\' expected an argument" % sys.argv[i])\n    return(1, sys.argv[i+1])\n\ndef PosArg(i):\n    \'\'\'Return positional argument\'\'\'\n    if i &gt;= len(sys.argv):\n        Fatal("\'%s\' expected an argument" % sys.argv[i])\n    return sys.argv[i]\n\ndef OptArg(i, default):\n    \'\'\'Return optional argument (if there is one)\'\'\'\n    if i &gt;= len(sys.argv):\n        Fatal("\'%s\' expected an argument" % sys.argv[i])\n    if sys.argv[i][:1] != \'-\':\n        return True, sys.argv[i]\n    else:\n        return False, default\n\n\n### MAIN\nif __name__==\'__main__\':\n\n    verbose = 0\n    debug   = 0\n    infile  = "infile"\n    outfile = "outfile"\n    options_start = 3\n\n    # --- Parse two positional parameters ---\n    n1 = int(PosArg(1))\n    n2 = int(PosArg(2))\n\n    # --- Parse an optional parameters ---\n    present, a3 = OptArg(3,50)\n    n3 = int(a3)\n    options_start += int(present)\n\n    # --- Parse rest of command line ---\n    skip = 0\n    for i in range(options_start, len(sys.argv)):\n        if not skip:\n            if   sys.argv[i][:2] == "-d": debug ^= 1\n            elif sys.argv[i][:2] == "-v": verbose ^= 1\n            elif sys.argv[i][:2] == "-i": (skip,infile)  = NextArg(i)\n            elif sys.argv[i][:2] == "-o": (skip,outfile) = NextArg(i)\n            elif sys.argv[i][:2] == "-h": HelpAndExit()\n            elif sys.argv[i][:1] == "-":  Fatal("\'%s\' unknown argument" % sys.argv[i])\n            else:                         Fatal("\'%s\' unexpected" % sys.argv[i])\n        else: skip = 0\n\n    print("Number 1 = %d" % n1)\n    print("Number 2 = %d" % n2)\n    print("Number 3 = %d" % n3)\n    print("Debug    = %d" % debug)\n    print("verbose  = %d" % verbose)\n    print("infile   = %s" % infile)\n    print("outfile  = %s" % outfile) \n</code></pre>\n'}]
['https://Stackoverflow.com/questions/20063', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1335/']