A helper for type-checked command-line argument store
Project description
init_attrs_with_kwargs
A helper for type-checked command-line argument store.
Sample
from init_attrs_with_kwargs import InitAttrsWKwArgs
class MyArgs(InitAttrsWKwArgs):
count: int
name: str
max_length: int
# Initialize from docopt's return value, with casting str to int
args: MyArgs = MyArgs(_cast_str_values=True, **{'<count>': '1', '--name': "Joe", '--max-length': '100'})
print("args.count=%s" % repr(args.count))
print("args.name=%s" % repr(args.name))
print("args.max_length=%s" % repr(args.max_length))
Another samples:
- sample1.py. Describes data type conversion and error handling.
- sample2.py. Storing
docopt
-parsed command line arguments in a type-hinted class's object.
Project details
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
Close
Hashes for init_attrs_with_kwargs-0.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcff79e16418c53d795278368e4d9d67daaf641d1261d69e576966c82c0bc428 |
|
MD5 | a44d43afe22aa3ecfbb5d39e3713ac4e |
|
BLAKE2b-256 | 5e546d25b24d6ebfce6d330da22b2adca973cb54c9c5c8269b83c743b26d0ee9 |
Close
Hashes for init_attrs_with_kwargs-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4eaeabf040b877bb5ae70319cbf3ae659d0481f39cf90e96bb678eaaa05db5b |
|
MD5 | 891aafa6b9000e145408d472c2067246 |
|
BLAKE2b-256 | 1aa2dc2484a1cdb9c12f66693e50c84d2531777f14ac061b9bbcca3e93e92f24 |