I\'m new to Python and trying to figure out how to filter out all the non-string keys in a dictionary. I appreciate any help you can provide.
For sake of variety of answers, here is another method:
>>> d = {1: 'ONE', 2: 'TWO', 3: 'THREE', 'T': 'THREE'} >>> b = {k:d[k] for k in filter(lambda s: type(s) is int, d.iterkeys())} >>> b {1: 'ONE', 2: 'TWO', 3: 'THREE'}