inputs for functions
Project description
Overview
The funcinputs project holds the class FuncInput. The objects of this class represent the entire input that can be passed to a function when the function is called. Each FuncInput object has a list of positional arguments (the property is called args) and a dict of keyword arguments (the property is called kwargs). One can do everything with a FuncInput object that can be done with a list or a dict e.g. indexers, appending, or updating.
Installation
To install funcinputs, you can use pip. Open your terminal and run:
pip install funcinputs
Usage
Once funcinputs is installed, you can use it as follows:
from funcinputs import FuncInput
x = FuncInput(args=[9, "foo"], kwargs={"bar":12.75})
print(x) # FuncInput(args=[9, 'foo'], kwargs={'bar': 12.75})
x += FuncInput(args=[2], kwargs={"baz":"spam"})
print(x) # FuncInput(args=[9, 'foo', 2], kwargs={'bar': 12.75, 'baz': 'spam'})
x.append(19)
print(x) # FuncInput(args=[9, 'foo', 2, 19], kwargs={'bar': 12.75, 'baz': 'spam'})
Features
The class FuncInput combines the features of list and dict:
Properties:
args: represents positional arguments in the shape of a list
kwargs: represents the keyword-arguments as a dict (the keys must be limited to the type str)
Methods:
append: Appends to args
clear_all: Combines clear_args and clear_kwargs
clear_args: Clears args
clear_kwargs: Clears kwargs
copy: Makes a copy
count: Counts in args
exec: Executes a function and returns the result
extend: Extends args
get: Gets value from kwargs
index: Gets index from args
insert: Inserts into args
items: Returns kwargs.items() converted to a list
keys: Returns kwargs.keys() converted to a list
pop: Pops value in kwargs if the key is of the type str, otherwise args
popitem: Pops item in kwargs
remove: Removes from args
reverse: Reverses args
setdefault: Sets default for kwargs
sort: Sorts args
update: Updates kwargs
values: Returns kwargs.values() converted to a list
Other Features:
addition: Creates a FuncInput object from two other objects. The property args and the property kwargs are each joined together
indexing: If the key is of the type str then kwargs is altered in the normal way, otherwise args
License
This project is licensed under the MIT License.
Links
Credits
Author: Johannes
Thank you for using funcinputs!
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
Built Distribution
File details
Details for the file funcinputs-1.1.2.tar.gz
.
File metadata
- Download URL: funcinputs-1.1.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 926ca33b6a741efb66cd1e30b635113fb5a2e4d309f0445388f71aa0b95718a7 |
|
MD5 | 7b87db6a2820198167db0d1399d5f70b |
|
BLAKE2b-256 | 82c81b5c134149ab252dd017e1fa7d5683a2110b4493c5c7d2f79a8e0f93b6d1 |
File details
Details for the file funcinputs-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: funcinputs-1.1.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ca068aa5447ee3379f02665b6a3f22aae2a2d8b92d202ab2cdcad8f06f3c495 |
|
MD5 | 84271bed57fb2e2db5750ab91a539bd1 |
|
BLAKE2b-256 | c397e9000328878c969cdebeba4c01d013562d3c9131e059f0b18cec2d0cadc1 |