Automatically select, check and bundle keyword arguments from 'kwargs' dictionaries
Project description
The documentation has not been created yet - sorry - you will have to make do with the following example code for now:
def exampleFct(aaa, bbb, **kwargs):
"""
:param aaa: just a dummy.
:param bbb: just a dummy.
:return: 'None'.
An example function for using 'ParamBundle' to automatically select,
check (for completeness and correct types) and bundle keyword arguments
into an instance of an enhanced dictionary class, which also and in
particular mirrors items to attributes and attributes to items
automatically.
"""
try:
### determine the mandatory as well as the optional parameters and belonging parameter types ###
### and extract, check and bundle the belonging parts of 'kwargs' into 'args'.
args = ParamBundle()
args.registerMandatories(ccc=int, ddd=float)
args.registerOptionals(eee=(int,float,type(None)), fff=None)
args.update( kwargs )
if args.isComplete() == False:
print (">>>>>>>>>> MANDATORY PARAMETERS INCOMPLETE <<<<<<<<<<")
except Exception as ee:
print ("Error in exampleFct: function called with wrong arguments (%s)!" % ee)
Furthermore you should try out:
python paramBundle.py --test
and have a look at the output! Last but not least the code of the belonging selftest() function and the functions called from there can provide some insights.
Further infomations and links can be found on my homepage
Have Fun!
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file paramBundle-0.50-py2.py3-none-any.whl
.
File metadata
- Download URL: paramBundle-0.50-py2.py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5849fe3ea1f6204e5eefb3afd47644384d683bcd8c612582ef74b3337499fd21 |
|
MD5 | d21e2dac030b3bf4fe93cc3ce208a5ef |
|
BLAKE2b-256 | 1ec1ed7778021c3c6ef2b5abfdc1f3bfc4536cce7c8beb45e016412535c82201 |