Suggestion: option to search for keys that have string in them #2

Closed
opened 2017-09-25 13:00:24 -04:00 by russellballestrini · 5 comments
russellballestrini commented 2017-09-25 13:00:24 -04:00 (Migrated from git2.unturf.com)

Created by: blark

I have a dict that uses "Email" and "Email__other" it would be great if you could add an option to search "if in key" instead of if key is equal to.

Thanks for putting this in pip. Saved me some time!

*Created by: blark* I have a dict that uses "Email" and "Email__other" it would be great if you could add an option to search "if in key" instead of if key is equal to. Thanks for putting this in pip. Saved me some time!
russellballestrini commented 2017-09-25 13:23:41 -04:00 (Migrated from git2.unturf.com)

Created by: russellballestrini

Interesting idea. Another option is creating a new function like multi_nested_lookup that changes key to keys and does an if k in keys. In this case we would recurse once and collect values for any number of deeply nested keys in one go. The returned result would have to be a dictionary of lists, instead of a list I think.

*Created by: russellballestrini* Interesting idea. Another option is creating a new function like `multi_nested_lookup` that changes `key` to `keys` and does an `if k in keys`. In this case we would recurse once and collect values for any number of deeply nested keys in one go. The returned result would have to be a dictionary of lists, instead of a list I think.
russellballestrini commented 2017-09-25 13:29:20 -04:00 (Migrated from git2.unturf.com)

Created by: russellballestrini

On second thought, I think your way is easier to implement and keeps the existing return behavior. I'll see what I can come up with today.

*Created by: russellballestrini* On second thought, I think your way is easier to implement and keeps the existing return behavior. I'll see what I can come up with today.
russellballestrini commented 2017-09-25 14:27:48 -04:00 (Migrated from git2.unturf.com)

Created by: russellballestrini

@blark let me know if this works for you and I'll cut a release on pypi:

https://github.com/russellballestrini/nested-lookup#wild

*Created by: russellballestrini* @blark let me know if this works for you and I'll cut a release on pypi: https://github.com/russellballestrini/nested-lookup#wild
russellballestrini commented 2017-09-26 09:52:30 -04:00 (Migrated from git2.unturf.com)

Created by: blark

Wow, you're quick ;) I'll give it a shot! Thanks.

*Created by: blark* Wow, you're quick ;) I'll give it a shot! Thanks.
russellballestrini commented 2017-09-26 09:59:36 -04:00 (Migrated from git2.unturf.com)

Created by: blark

Works great. Thanks again.

*Created by: blark* Works great. Thanks again.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: python/nested-lookup#2
No description provided.