argparse and default values

Andrea Crotti andrea.crotti.0 at gmail.com
Thu Jan 5 08:29:34 EST 2012


On 01/05/2012 01:24 PM, Andrea Crotti wrote:
> There's one thing I don't understand about argparse, why doesn't
> --help show what is the default value??
> I mean if I add an option that can be customized it would be good for 
> the user
> to know what is the current value in my opinion.
>
> Is there a way to make it show it?

Looking at the code I found it already
     parser = argparse.ArgumentParser(description=description,
                                      
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

the only thing is that it displays also "default: None" which isn't 
probably very useful,
but it would easy to write my own formatter and pass it if I don't like 
this..



More information about the Python-list mailing list