kc
Utils for filtering
To install: pip install kc
Overview
The kc package provides utility functions for creating filters that can be applied to data collections in Python. These filters allow for inclusion or exclusion of elements based on specified criteria. The package is particularly useful for filtering lists, tuples, or other iterable collections based on dynamic conditions.
Main Functions
mk_inclusion_exclusion_filter
This function creates a filter based on both inclusion and exclusion criteria. It returns a filter function that can be used with Python's built-in filter() function.
-
Parameters:
include: List-like collection of elements to include.exclude: List-like collection of elements to exclude.key: A function or a key to apply to elements of the iterable for comparison.
-
Usage Example:
# Inclusion only filt = mk_inclusion_exclusion_filter(include=[2, 4]) print(list(filter(filt, [1, 2, 3, 4, 5]))) # Exclusion only filt = mk_inclusion_exclusion_filter(exclude=[2, 4]) print(list(filter(filt, [1, 2, 3, 4, 5]))) # Inclusion and Exclusion filt = mk_inclusion_exclusion_filter(include=[1, 2, 3, 4], exclude=[1, 3]) print(list(filter(filt, [1, 2, 3, 4, 5])))
mk_inclusion_filter
Creates a filter that includes elements if they are in the specified include list.
-
Parameters:
include: List-like collection of elements to include.key: A function or a key to apply to elements of the iterable for comparison.
-
Usage Example:
filt = mk_inclusion_filter(include=[2, 4]) print(list(filter(filt, [1, 2, 3, 4, 5])))
mk_exclusion_filter
Creates a filter that excludes elements if they are in the specified exclude list.
-
Parameters:
exclude: List-like collection of elements to exclude.key: A function or a key to apply to elements of the iterable for comparison.
-
Usage Example:
filt = mk_exclusion_filter(exclude=[2, 4]) print(list(filter(filt, [1, 2, 3, 4, 5])))
Installation
To install the kc package, use the following command:
pip install kc
Contributing
Contributions to the kc package are welcome. Please ensure that any pull requests or issues are clear and provide sufficient information for review.
Metadata
Release files for kc 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kc-0.0.7.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kc-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.5 kB
Release files / kc-0.0.7.tar.gz
| Download URL | kc-0.0.7.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8c31b06d930645a8056b9e6b78862a4ef918742a665274408eac4f4ac9e8ba8
|
|
BLAKE2b-256 checksum How to use checksums |
e070d85a09db1b10de3d935cc4464b141252211bd34afaddbb688fe9d5d0c8d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / kc-0.0.7-py3-none-any.whl
| Download URL | kc-0.0.7-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc12d77790eb26a02f788fcaeee53d231150fe715ef9cbf94cab41ed487ba9fe
|
|
BLAKE2b-256 checksum How to use checksums |
de8242934bbb69fc3da391fd0e0206a51ab702d705aa8a4bfe272da80100e658
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|