Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dict get_all() #266

Open
kurtbrose opened this issue Oct 14, 2020 · 3 comments
Open

dict get_all() #266

kurtbrose opened this issue Oct 14, 2020 · 3 comments

Comments

@kurtbrose
Copy link
Contributor

def get_all(map, **defaults):
   return {key: map.get(key, default) for key, default in defaults.items()}

found this to be handy e.g. when extracting data from query parameters, flags or similar

very concise way to normalize an input dict by extracting only the keys you are interested in, and defaulting and missing keys

@mblahay
Copy link
Contributor

mblahay commented Nov 13, 2020

I like it. Not sure about the name, but it is an elegant solution to a common problem.

@mblahay
Copy link
Contributor

mblahay commented Nov 13, 2020

I just noticed there is no pull request. Are you planning on submitting one?

@kurtbrose
Copy link
Contributor Author

would you like to get your name in the contributors? :-) please feel free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants