the.bay.news

Query multiple dictionary keys

Discussions on Python.org
Query multiple dictionary keys
In python today, you can query a dictionary like so, d['some_key'] but you can only query one key at a time. If you attempt to query the dictionary using d[['key_a','key_b']] it returns with TypeError: unhashable type: 'list' I propose that we add in so d[['key_a','key_b']] works the same way {key:value for key,value in d.items() if key in ['key_a','key_b']} works now, allowing users to quickly get multiple keys from a dictionary. I believe this is an intuitive way to query multiple keys, it ...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.