On Fri, Dec 27, 2019, at 23:08, jf...@ms4.hinet.net wrote: > > > optional arguments: > > > -h, --help show this help message and exit > > > --foo [FOO] foo help > > > --goo GOO goo help > > > > > > D:\Works\Python>py test.py --foo 1 --goo 2 > > > 1 ['2'] > > So the square bracket means optional, not list? My misunderstanding:-(
To be clear, the brackets in the print output do mean a list, and it is because nargs=1 produces a list rather than the default (no nargs) which is to produce a single value. This is not normally visible to the end user (it's just a difference in how your program consumes the one mandatory argument), so it's not reflected in the help output. Square brackets in the help output mean an optional argument. -- https://mail.python.org/mailman/listinfo/python-list