understreck package¶
Submodules¶
understreck.chunks module¶
understreck.exceptions module¶
understreck.filter module¶
-
understreck.filter.
filter
(to_filter, filter_to_apply)[source]¶ Filters a list or tuple
- Examples:
- users = [
- {“user”: “barney”, “age”: 36, “active”: True}, {“user”: “fred”, “age”: 40, “active”: False},
]
# Using a lambda function result = _.filter(users, lambda x: not x.get(“active”)) result == [{“user”: “fred”, “age”: 40, “active”: False}]
# Using partial dictionary result = _.filter(users, {“age”: 36, “active”: True}) result == [{“user”: “barney”, “age”: 36, “active”: True}]
# Using a list with a property name and value result = _.filter(users, [“active”, False]) result == [{“user”: “fred”, “age”: 40, “active”: False}]
# Using a list with a property name. The value must be truthy. result = _.filter(users, [“active”]) result == [{“user”: “barney”, “age”: 36, “active”: True}]
Parameters: - to_filter – the tuple or list to filter
- filter_to_apply – A function or list that defies the filter
Returns: A filtered list or tuple with the same type as to_filter
understreck.nested_get module¶
-
understreck.nested_get.
get
(input_dict, nested_key)¶ Get a subkey from a dict
This will return a subkey from a dictionary. It solves a problem when having to perform safe get on nested dictionaries.
- Arguments:
input_dict {dict} – The dictionary to perform the get on nested_key {str, list, tuple} – The key can be or dot delimited string
or list/tuple.- Returns:
- Object or None – The value of the key or None
-
understreck.nested_get.
nested_get
(input_dict, nested_key)[source]¶ Get a subkey from a dict
This will return a subkey from a dictionary. It solves a problem when having to perform safe get on nested dictionaries.
- Arguments:
input_dict {dict} – The dictionary to perform the get on nested_key {str, list, tuple} – The key can be or dot delimited string
or list/tuple.- Returns:
- Object or None – The value of the key or None
understreck.strip module¶
Module contents¶
Top-level package for Understreck.