argparse.ArgumentParser("blah")

Roy Smith roy at panix.com
Sun Oct 23 13:37:40 EDT 2011


As I read the docs (http://tinyurl.com/3ww9scr), the following two calls 
should result in the same object:

parser = argparse.ArgumentParser(description="blah")
parser = argparse.ArgumentParser("blah")

In the first case, I'm explicitly setting description to "blah", in the 
second case, I'm passing "blah" as a positional parameter so it should 
be taken as first parameter to the function, which happens to be 
description.  Either way should end up the same.

I don't, however, get the same behavior when run with "-h".  The first 
gives what I would expect:

------------------------------------------------
usage: arg.py [-h]

blah

optional arguments:
  -h, --help  show this help message and exit
------------------------------------------------

and the second gives:

------------------------------------------------
usage: blah [-h]

optional arguments:
  -h, --help  show this help message and exit
------------------------------------------------

Is this a bug, or am I just not reading the docs right?



More information about the Python-list mailing list