A set of Python regularly used classes/functions
Project description
Dev4py-utils
A set of Python regularly used classes/functions
Table of contents
Project template
This project is based on pymsdl_template
Project links
Dev4py-utils modules
dev4py.utils.JOptional
Note: JOptional class is inspired from java.util.Optional class with some adds (like
peek
method).
Examples:
from dev4py.utils import JOptional
value = 1
JOptional.of_noneable(value).map(lambda v: f"The value is {v}").if_present(print)
dev4py.utils.objects
Note: The objects module is inspired from java.util.Objects class.
Examples:
from dev4py.utils import objects
# non_none sample
value = None
objects.non_none(value)
# require_non_none sample
value = "A value"
objects.require_non_none(value)
# to_string sample
value = None
default_value: str = "A default value"
objects.to_string(value, default_value)
dev4py.utils.types
Note: The types module is inspired from java.util.function package
Examples:
from dev4py.utils.types import Function, Predicate, Consumer
# Function sample
int_to_str: Function[int, str] = lambda i: str(i)
str_result: str = int_to_str(1)
# Predicate sample
str_predicate: Predicate[str] = lambda s: s == "A value"
pred_result = str_predicate("Value to test")
# Consumer sample
def sample(consumer: Consumer[str], value: str) -> None:
consumer(value)
def my_consumer(arg: str) -> None:
print(arg)
sample(my_consumer, "My value")
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
dev4py-utils-2.0.0.tar.gz
(19.7 kB
view hashes)
Built Distribution
Close
Hashes for dev4py_utils-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4177d0ca78ccaa8c2970c156417d6e449cbe80daed7ec37817ff8968fafb5869 |
|
MD5 | 8b9a7c18e57cf9c5919dc47cc59661d4 |
|
BLAKE2b-256 | e70124f8d21017a3297f3fe3042a86e82fb46fca6062a685fe1f41c2cbf5ad32 |