how to scrutch a dict()

Phlip phlip2005 at gmail.com
Thu Oct 21 06:32:08 CEST 2010


Not Hyp:

def _scrunch(**dict):
    result = {}

    for key, value in dict.items():
        if value is not None:  result[key] = value

    return result

That says "throw away every item in a dict if the Value is None".

Are there any tighter or smarmier ways to do that? Python does so
often manage maps better than that...

--
  Phlip
  http://zeekland.zeroplayer.com/



More information about the Python-list mailing list