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.

Metadata

Release files for argparse-addons 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for argparse-addons 0.8.0
File Size Uploaded
argparse_addons-0.8.0.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for argparse-addons 0.8.0
File Interpreter ABI Platform
argparse_addons-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / argparse_addons-0.8.0.tar.gz

Download URL argparse_addons-0.8.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bb088107944d339e8d2e70a76305dde351544e2c5bdebaf1c2db56ad2e6dcde8
BLAKE2b-256 checksum
How to use checksums
597f14297cea44ad89bb94f5776b1a8db1b4c804167be25f42b03e62840edaf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / argparse_addons-0.8.0-py3-none-any.whl

Download URL argparse_addons-0.8.0-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e68f3f9221f32dc4942801e5d36e9e4b60867abffc10b18e72cf1bf10f27fd4a
BLAKE2b-256 checksum
How to use checksums
09f0dee72e2b51c8e987ba7a7fa923f650c5007a41d3fb85be2fb7ecabfdd4ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release history Release notifications | RSS feed

0.12.0

2 release files

0.11.0

2 release files

0.9.0

2 release files

This release

0.8.0 This release

2 release files

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page