I\'ve got a dict
that has a whole bunch of entries. I\'m only interested in a select few of them. Is there an easy way to prune all the other ones out?
You could use python-benedict
, it's a dict subclass.
Installation: pip install python-benedict
from benedict import benedict
dict_you_want = benedict(your_dict).subset(keys=['firstname', 'lastname', 'email'])
It's open-source on GitHub: https://github.com/fabiocaccamo/python-benedict
Disclaimer: I'm the author of this library.