Joost Molenaar <j.j.molen...@gmail.com> writes:

> Using a 2.7/3.x dictionary comprehension, since you don't seem to mind
> creating a new dictionary:
>
> def _scrunched(d):
>     return { key: value for (key, value) in d.items() if value is not None }

Note that a dict comprehension, while convenient, is not necessary for
this to be formulated as a single expression:

def _scrunched(d):
    return dict((key, value) for (key, value) in d.items() if value is not None)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to