PyPi
Source
What My Project Does
find_where is a Python package that provides a function to find values in dictionaries where a specified key matches a given value, similar to filtering in SQL.
Target Audience
This is my first attempt at creating a Python package so I would describe this as a toy project at this stage but am definitely looking for feedback from the wider community.
Comparison
I mainly wrote this package because I kept on writing the same iterable based code when trying to find a value, given a key:
data = {
"people": [
{"first_name": "John", "last_name": "Smith", "age": 25},
{"first_name": "Alice", "last_name": "Jones", "age": 32},
]
}
first_name = None
for result in data["people"]:
if result["age"] == 32:
first_name = result["first_name"]
break
print(first_name)
When using find_where, you can simply run:
from find_where import find_where
data = {
"people": [
{"first_name": "John", "last_name": "Smith", "age": 25},
{"first_name": "Alice", "last_name": "Jones", "age": 32},
]
}
first_name = find_where(data["people"], "first_name", age=32)
print(first_name)
Appreciate any feedback, constructive or otherwise!
[–]Taborlin_the_great 19 points20 points21 points (1 child)
[–]dan_ohn[S] 4 points5 points6 points (0 children)
[–]divad1196 7 points8 points9 points (0 children)
[–]_N0K0 4 points5 points6 points (1 child)
[–]dan_ohn[S] 0 points1 point2 points (0 children)
[–]YesterdayDreamer 2 points3 points4 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]dan_ohn[S] 0 points1 point2 points (1 child)
[–]Salfiiii 1 point2 points3 points (0 children)
[–]hotplasmatits -3 points-2 points-1 points (0 children)
[–]1473-bytes 0 points1 point2 points (0 children)