argparse custom types
Project description
argparse-custom-types
Special custom types for argparse
How to install
pip install argparse_custom_types
Description
Additional custom types to be used with argparse
How to use
Import argparse_custom_types setup the custom type then pass the function to the type keyword in argparse.add_argument()
Types
-
int_range
- custom int in range from start to stop (not including) optional step
def int_range(start: int, stop: int, step: int = 1):
- example:
t = int_range(5, 21, 5)
int types 5, 10, 15, 20 would be accepted
-
int_above
def int_above(minimum: int):
- int equal to or above the minimum entered
- example:
t = int_above(40)
int types 40 and above would be accepted
-
int_below
def int_below(maximum: int):
- int equal to or below maximum
- example:
t = int_below(25)
int types 25 or below would be accepted
-
int_even
def int_even(pos_number: bool = True, neg_number: bool = False,include_zero: bool = False):
- even int with option to include negative, zero or exclude positive
- example:
t = int_even(neg_number=True)
int types 2, -30, 102 would be accepted int types 1, -29, 101 would not be accepted
-
int_odd
def int_odd(pos_number: bool = True, neg_number: bool = False,include_zero: bool = False):
- odd int with option to include negative, zero or exclude positive
- example:
t = int_odd(neg_number=True)
int types 1, -29, 101 would be accepted int types 2, -30, 102 would not be accepted
-
in_sequence_strings
def in_sequence_strings(sequence: Union[Tuple[str], List[str]], show_on_invalid: bool = False, case_sensitive: bool = True):
- Value that is in the tuple or list and returns that value as a string.
- example:
t = in_sequence_strings(["one", "test", "parser"])
any value not in the list ["one", "test", "parser"] will not be accepted
-
in_sequence_ints
-
def in_sequence_ints(sequence: Union[List[int], Tuple[int]], show_on_invalid: bool = False):
- Int value in sequence will be accepted and return a int value
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
Built Distribution
File details
Details for the file argparse_custom_types-0.2.0.tar.gz
.
File metadata
- Download URL: argparse_custom_types-0.2.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9bb00b634778c620e3e4bda996fe1e62af0a6eb8128c16d515d1e2dd0122c9d |
|
MD5 | dc4939cc73d593daee8b22737f369269 |
|
BLAKE2b-256 | 02512a1d5e39e44c438e46e79dd78a20a4b0b282e1bb948ef0a7cf110342276b |
File details
Details for the file argparse_custom_types-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: argparse_custom_types-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.0 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/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98575360e2839e7b989ed68f6358577c2ef6cbd394da7a6de6519fb0623da6f9 |
|
MD5 | 7bf47a9855f7f874fec3474167ad7161 |
|
BLAKE2b-256 | d8a6c2f941c0f3a0b021436fbf433b176acf654f0485c81428fe2eef3d6d73aa |