optparse

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Sep 16 15:46:09 EDT 2008


On Tue, 16 Sep 2008 21:35:05 +0200, Torsten Mohr wrote:

> parser.add_option("-v", "--verbose",
>                   dest = 'verb',
>                   help = 'be loud',
>                   action = 'store_true',
>                   default = 'store_false')
> 
> (opts, args) = parser.parse_args()
> 
> print "opts", opts
> print "args", args
> ------example
> 
> If i call it without any parameters i get:
> 
> opts {'verb': 'store_false'}
> args []
> 
> 
> I would rather like to see the actual value False in "opts", did i use
> some wrong parameters somewhere?

if you want `False` as default you should actually use `False` and not 
the string 'store_false'.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list