Skip to main content

Command line argument parsing library for python

Project description

Argument parsing for python developers


import argument
f = argument.Arguments()
#Requried arguments, first argument will be stored as "candy"
f.required("candy", help="Candy name")
#optional value, set a default, can be changed by adding: --num=30, or -n=30
    help="How many pieces?",
#add a switch, a flag with no argument
    help="Reverse ordering",
#Process data before saving it
f.process("candy", lambda x: x.upper())

#get data
arguments, errors = f.parse()


python tests/ bubblegum

{‘num’: 25, ‘reverse’: False, ‘candy’: ‘BUBBLEGUM’}

python tests/ bubblegum -r -n=123

{‘num’: 123, ‘reverse’: True, ‘candy’: ‘BUBBLEGUM’}

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

argument-0.2.4.tar.gz (4.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page