optional args for getopt()

Will Ware wware at world.std.com
Wed Aug 22 23:37:47 EDT 2001


bvdpoel at uniserve.com wrote:
> Is there a way to signal that the arg for getopt in optional. In C I can
> set an option string to something like:
> 	opts = "hg:b::"
> which means that 'g' needs an arg and that 'b' may have an arg. Seems
> the python routine is lacking?? 

Looking here: http://www.python.org/doc/current/lib/module-getopt.html
it appears you're out of luck.

What does the C version do if you type "program -b -g" ? Does it assume
that the leading hyphen on the "g" implies that it's another option, as
opposed to an argument of the "b" option?

-- 
-----------------------------------+---------------------
 22nd century: Esperanto, geodesic | Will Ware
 domes, hovercrafts, metric system | wware at world.std.com



More information about the Python-list mailing list