Delete None values from Python dict
python
Solution
result = default.copy()
result.update((k, v) for k, v in user.iteritems() if v is not None)
Problem
Newbie to Python, so this may seem silly. I have two dicts: ``` default = {'a': 'alpha', 'b': 'beta', 'g': 'Gamma'} user = {'a': 'NewAlpha', 'b': None} ``` I need to update my defaults with the values that exist in user. But only for those that have a value not equal to None. So I need to get back a new dict: ``` result = {'a': 'NewAlpha', 'b': 'beta', 'g': 'Gamma'} ```