Giter Club home page Giter Club logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
I'm a little nervous about doing this for all help messages because sometimes 
the
Python object used as a default doesn't make sense (e.g. a function object). 
You can
use string format specifiers in the help messages though, like this::

  >>> parser = argparse.ArgumentParser()
  >>> parser.add_argument('--foo', type=int, default=123,
  ...                     help='Foo something (default: %(default)s)')
  >>> parser.print_help()
  usage: argparse.py [-h] [--foo FOO]

  optional arguments:
    -h, --help  show this help message and exit
    --foo FOO   Foo something (default: 123)

Is that enough, or are you hoping for a help formatter that automatically adds
(default: xxx) to the end of everything with a non-None default?

Original comment by [email protected] on 28 Mar 2009 at 2:09

from argparse.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
I, for one, would like to see such a formatter. It should probably try to check 
that
'%(default)' is not already in the string, though. I might want to override the
formatting for one argument.

Original comment by [email protected] on 6 Jun 2009 at 10:06

from argparse.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
Yeah, checking for '%(default)' makes a lot of sense. I'll try to add this 
feature
before the next release of argparse. It'll probably come in the form of a new
subclass of HelpFormatter.

Original comment by [email protected] on 10 Jun 2009 at 2:18

  • Changed state: Accepted

from argparse.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
I finally got around to this. There's now a ArgumentDefaultsHelpFormatter as of 
r28
which adds ' (default: %(default)s)' to all the help strings where the argument 
has a
default.

Original comment by [email protected] on 13 Jul 2009 at 12:04

  • Changed state: Fixed

from argparse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.