More pythonic way of updating an existing value in a dictionary
<p>Lets assume I got a dictionary <code>_dict</code> and a variable <code>n</code>.</p>

<pre><code>_dict = {'a': 9, 'b': 7, 'c': 'someValue'}
n = 8
</code></pre>

<p>I want to update just a single entry e.g. <code>{'b': 7}</code> only if the value of <code>n</code> is greater than the actual value of <code>b</code>.
The solution I got so far is</p>

<pre><code>_dict.update({'b': n for key, value in _dict.items() if key == 'b' and n &gt; value})
</code></pre>

<p>Which provides the desired result of <code>{'a': 9, 'b': 8, 'c': 'someValue'}</code>. So now to my question: Is there a shorter, more pythonic way of doing this? (preferably without importing additional modules)</p>

<pre><code>if n &gt; _dict['b']:
   _dict['b'] = n
</code></pre>

python dictionary