seanpianka / Zipcodes

A simple library for querying U.S. zipcodes.
MIT License
78 stars 15 forks source link

Expand filter functionality #6

Closed godsylla closed 4 years ago

godsylla commented 4 years ago

This is more of a "feature request" than it is an issue. I'd love it if there was functionality to filter on any of the other keys in the returned dictionary when searching for a zip code.

For example: zipcodes.filter_by(county="Los Angeles")

would return something like a list of dictionaries with all of the zip codes inside Los Angeles County :)

BTW, thanks for developing this. It's been a great tool so far.

seanpianka commented 4 years ago

Hi @godsylla and thanks for opening this feature request. Can you help me to understand what exactly you're wanting to do, and why that's not possible currently?

If I run your example code, I receive zero results. However, if I modify the county name value to be a valid county name, e.g. zipcodes.filter_by(county="Los Angeles County"), I get a long list of results.

crsharat commented 4 years ago

@seanpianka Instead of a long list, we could have a generator, which contains another generator of the list of Zipcode objects, having attributes like country, timezone, area codes, world region, etc., a number of zip codes matched and total zipcode count.

seanpianka commented 4 years ago

Hi @crsharat, thanks for your comment.

I am open to the idea of using a generator instead of large lists, as I can imagine there are performance benefits at scale.

However, I am not interested in a new major release right now, so modifying the package's interface to return Zipcode typed objects is a no from me. I like the dictionary return type, as its a simple interface that works everywhere without a developer having to understand the behavior of a custom object.

If you are interested in using a generator, please open a separate issue.

seanpianka commented 4 years ago

@godsylla, feel free to re-open the issue if you have remaining questions.