Help your python code have parameters and arguments
Project description
easyarg
Create a parameter
from easyarg import AGR
parser=AGR()
# create two parameters --say and --cry
parser.add_agr('--say')
parser.add_agr('--cry')
# read all parameters and arguments, this is a required function
parser.parse_agrs()
# return argument of --say and --cry
say_data=parser.get_value('--say')
cry_data=parser.get_value('--cry')
print(say_data)
print(cry_data)
# Run it on terminal like this
# python yourfile.py --say "hello this is my test" --cry huhu
# output: hello this is my test
# huhu
If you want a parameter to have a default argument,this default value can be changed.
from easyarg import AGR
parser=AGR()
parser.add_agr('--say',default='hello world')
parser.parse_agrs()
say_data=parser.get_value('--say')
print(say_data)
# this is default:
# output: hello world
# change value:
# python yourfile.py --say "hello this is my test"
# output: hello this is my test
If you just want to add parameters without arguments
from easyarg import AGR
parser=AGR()
parser.add_agr('--help',action='store_true')
parser.parse_agrs()
help_data=parser.get_value('--help')
if help_data:
print('User entered help')
# python yourfile.py --help
# output: User entered help
Thanks from Phan Huynh Thien Phu
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
easyarg-0.2.0.tar.gz
(2.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easyarg-0.2.0.tar.gz.
File metadata
- Download URL: easyarg-0.2.0.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c8d79873e1c1fb355c2c9a15c8bc7a56c08ed5e556d2def3e114e0c0ca674a0
|
|
| MD5 |
dbd9c8d50e9be3232c4759c2093bfa7a
|
|
| BLAKE2b-256 |
a6b661b14c2950ac8866ae9a6523d271adf236cbe66ff162415f88a649fa2033
|
File details
Details for the file easyarg-0.2.0-py3-none-any.whl.
File metadata
- Download URL: easyarg-0.2.0-py3-none-any.whl
- Upload date:
- Size: 2.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a229e39b47c9ac229bc169aea226fb0d4f277348273036438f26954997532313
|
|
| MD5 |
9d39179fa2df07deeb914773af652a78
|
|
| BLAKE2b-256 |
b10673168fed29d39833db7fe8d8f173fbbcc1e079a4421f6cbbaa36058691c9
|