argupy
Easy-to-use argument manager for Python3.
Instalation
To install argupy, run
pip3 install argupy
Usage
To use it in a Python script, first you need to import it.
from argupy import *
Then, initialize the Args class
argupy = Args()
and define any parameters you'll want to use later on.
argupy.setarg('--testarg', BOOL)
You can optionally pass a list of parameters to Args(), but if you don't, it defaults to sys.argv. The first item will be ignored.
The setarg function takes these parameters:
- name: the parameter name, for example, '--test'.
- type_: the parameter type, pass a constant like
BOOL,STR,INT, orFLOAT. Note the underscore to prevent conflicts with the built-intype()function. - default_value: optional. The default value to return if the argument is not present. Defaults to
Falseif the argument is of typeBOOL. - short: optional. The short name for the argument, usually one letter. For example, long:
--help, short:-h.
To use short names, do it like this:
argupy.setarg('--testarg', BOOL, short='-t')
To define an argument which takes a value, use the types STR, INT or FLOAT. Then retreive it with the Args.arg() method.
argupy.setarg('--testarg', STR)
value = argupy.arg('--testarg')
print(type(value), value)
# Running this code like this:
# python3 file.py --testarg hello
# would output: <class 'str'> hello
If the argument type is set to STR, the returned value will be of type str. And again, if the argument is of type INT or FLOAT, the returned value will be of type int or float, so you don't have to pass it through int() or float(). Unless the argument is not present and the default value you specify is not of the corresponding type.
To pass STR values with spaces, put double-quotes around them, like this:
python3 file.py --testarg "Chicago, Los Angeles"
Also, for debugging purposes, if you print an argument like this
print(argupy.args['--testarg'])
the output will be something like:
Arg(name='--testarg', type_='boolean', default_value=False)
or
Arg(name='--testarg', type_='boolean', default_value=False, link=True, target='--anotherarg')
or
Arg(name='--testarg', type_='boolean', default_value=False, links=['--anotherarg'])
Metadata
Release files for argupy 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| argupy-0.0.3.tar.gz | 2.5 kB | Without provenance | Details for argupy-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| argupy-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for argupy-0.0.3-py3-none-any.whl |
Total release size: 16.9 kB
Release files / argupy-0.0.3.tar.gz
| Download URL | argupy-0.0.3.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99e870c79ee919bf95e609ab4ef27a2344bdd15cdc62d7d62ab49038b2056c02
|
|
BLAKE2b-256 checksum How to use checksums |
1534cf83d0642badb3cc51ded19eb1063d3be243eafecf75da51c7e4d3bb354b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1
|
Release files / argupy-0.0.3-py3-none-any.whl
| Download URL | argupy-0.0.3-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
babe7251a282d1ce91e872f832a98dc2e9dff01c88db05e0d71de1e6fcd685d1
|
|
BLAKE2b-256 checksum How to use checksums |
88b73329da58e56138fd75e3191f67f7bfe57ac3e72b86344260aad0241fff85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1
|
Security for argupy 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.