utils.safely

utils.safely

Functions

Name Description
filter_nones Filter lists based on the presence of None values.
safely A decorator for more graceful failing.

filter_nones

utils.safely.filter_nones(filterer, to_filter)

Filter lists based on the presence of None values.

Usage:

# on a single list
from fasttrackpy.utils.safely import filter_nones
a = [1, 2, None, 6]

# value unpacking
a, = filter_nones(a, [a])
print(a)
[1, 2, 6]
from fasttrackpy.utils.safely import filter_nones
a = [1, 2, None, 6]
b = ["a", "b", "c", "d"]

a,b = filter_nones(a, [a,b])
print(a)
print(b)
[1, 2, 6]
['a', 'b', 'd']

Parameters

Name Type Description Default
filterer Sequence The filterer list that may contain None values required
to_filter list[Sequence] A list of lists to filter. required

Returns

Type Description
list[Sequence] list[Sequence]: description

safely

utils.safely.safely(message=f'There was a problem a function's application.')

A decorator for more graceful failing. If the decorated function raises an exception, it will return None.

Parameters

Name Type Description Default
message str A warning message in the case of an exception. Defaults to f"There was a problem a function's application.". f'There was a problem a function's application.'