Skip to main content

About

Additional Python argparse types and actions.

Project homepage: https://github.com/eerimoq/argparse_addons

Installation

$ pip install argparse_addons

Examples

Integer type

The script. See examples/integer.py for the complete script.

parser.add_argument('--min-max',
                    type=argparse_addons.Integer(0, 255))
parser.add_argument('--min',
                    type=argparse_addons.Integer(0, None))
parser.add_argument('--max',
                    type=argparse_addons.Integer(None, 255))
parser.add_argument('--any',
                    type=argparse_addons.Integer())

Error message for the --min-max argument.

$ python3 examples/integer.py --min-max -1
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --min-max: -1 is not in the range 0..255

Error message for the --min argument.

$ python3 examples/integer.py --min -1
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --min: -1 is not in the range 0..inf

Error message for the --max argument.

$ python3 examples/integer.py --max 1000
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --max: 1000 is not in the range -inf..255

Error message for the --any argument.

$ python3 examples/integer.py --any a
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --any: invalid integer value: 'a'

All values within allowed ranges.

$ python3 examples/integer.py --min-max 47 --min 1000 --max -5 --any 1
--min-max: 47
--min:     1000
--max:     -5
--any:     1

Contributing

  1. Fork the repository.

  2. Install prerequisites.

    pip install -r requirements.txt
  3. Implement the new feature or bug fix.

  4. Implement test case(s) to ensure that future changes do not break legacy.

  5. Run the tests.

    make test
  6. Create a pull request.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

argparse_addons-0.12.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argparse_addons-0.12.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file argparse_addons-0.12.0.tar.gz.

File metadata

  • Download URL: argparse_addons-0.12.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for argparse_addons-0.12.0.tar.gz
Algorithm Hash digest
SHA256 6322a0dcd706887e76308d23136d5b86da0eab75a282dc6496701d1210b460af
MD5 65918f16a8ffee0069ac801814693b1b
BLAKE2b-256 9e3533ecca1cdbebc5397a77f66edbc20ab76265176f7e3511b7696008ad9038

See more details on using hashes here.

File details

Details for the file argparse_addons-0.12.0-py3-none-any.whl.

File metadata

File hashes

Hashes for argparse_addons-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48b70ecd719054fcb0d7e6f25a1fecc13607aac61d446e83f47d211b4ead0d61
MD5 e3c9625605b88b62ea342a72e2d3d1cf
BLAKE2b-256 c141629e70c4cb32c1ddb88de970cd174bbb43d8241c8e07bdffc62a8280297c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.12.0 This release

2 files

0.11.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

1 file

0.6.0

1 file

0.5.0

1 file

0.4.0

1 file

0.3.0

1 file

0.2.0

1 file

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page