NAAM
No Argparse Any More.
Don’t google argparse just take some NAAM
I forget how to use argparse every time I make utilities
10+ lines for just parsing arguments? No way!
There should be a super pythonic way to parse arguments!!!!
Install
pip install naam
How to use it
Just decorate your main function like @naam.bind_args and execute it!
Example
Here’s a code (placed in examples/optional.py):
from naam import bind_args
@bind_args
def hello(first_name, last_name=None):
msg = 'Hello world! My name is %s.'
if last_name is None:
print(msg % first_name)
else:
print(msg % '{} {}'.format(first_name, last_name))
hello()
With empty arguments, this outputs:
Usage: optional.py [-l LAST_NAME | --last_name LAST_NAME] FIRST_NAME
With arguments, this outputs like:
$ python optional.py Miku Hello world! My name is Miku. $ python optional.py Miku --last_name Hatsune Hello world! My name is Miku Hatsune. $ python optional.py Miku -l Hatsune Hello world! My name is Miku Hatsune.
Prerequisites
No dependencies. Works on Python 3.x (Built on Python 3.6.2).
Features I crave
Type casting for type-annotated args
Metadata
Release files for naam 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| naam-0.1.1.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| naam-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 kB
Release files / naam-0.1.1.tar.gz
| Download URL | naam-0.1.1.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b728514e85537d09c64920169ea3735fdcac16f0c54e27984115943bca5ca15
|
|
BLAKE2b-256 checksum How to use checksums |
2965a018e9741b738779cf2e38858a104a98624e0751b7913f5069e1a1939375
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / naam-0.1.1-py3-none-any.whl
| Download URL | naam-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3716131aa89210a2ea8933f1325515bba837b912d07ccc8d63a905e658f8572a
|
|
BLAKE2b-256 checksum How to use checksums |
efe3ec4deaad7f83ec46bcc248444abeb09bd9c14e8526fd03d306ade86ab64d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |