addition types to use with argparse
Project description
argparse_types
Special argparse types
How to install
pip install argparse-types
description
Additional types to use with argparse
how to use
Import argparse_types pass the argparse_types."type" to the type keyword in argparse.add_argument. Remember to pass not to call.
example.py
import argparse
import argparse_types
parser = argparse.ArgumentParser()
parser.add_argument("-n", dest="number", type=argparse_types.pos_int)
args = parser.parse_args()
print(args.number)
python3 example.py -n 34
34
python3 example.py -n -34
example.py: error: argument -n: -34 is an invalid positive int value
types
- pos_int - Positive int value not including 0
- neg_int - Negative int value not including 0
- zero_int - Zero int value
- pos_float - Positive float value not including 0
- neg_float - Negative float value not including 0
- zero_float - Zero float value
- int_float - Any int or float value
- bool_none - True, False, None value
- ip4 - ip address 0.0.0.0 to 255.255.255.255 not including port
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
argparse_types-0.2.0.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file argparse_types-0.2.0.tar.gz
.
File metadata
- Download URL: argparse_types-0.2.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6908c7dd6cb36f15313ff85f74a3f3a8fa66e6d425bfb5126d59bc0711f2c149 |
|
MD5 | a6ecd66afe85ab44234b9f2e6276c0d0 |
|
BLAKE2b-256 | c12582fdd53b38db713f46ca6d7a63a2669003c56c2972b8f904f221d8052eb4 |
File details
Details for the file argparse_types-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: argparse_types-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c59cb0dd19a0cf56d68aaed89607558d103423c0d78b24b6437729def3c0f9be |
|
MD5 | 98828e4400de81524d6d43229ffdae3d |
|
BLAKE2b-256 | 84ab9139537c87bdecb4f8df26a0da4e71588637232c8d834911fc089f5ca0dc |