Is there a pythonic way to update a dictionary value when the update is dependent on the value itself?
<p>I find myself in a lot of situations where I have a dictionary value that I want to update with a new value, but only if the new value fulfils some criteria relative to the current value (such as being larger).</p>

<p>Currently I write expressions similar to:</p>

<pre><code>dictionary[key] = max(newvalue, dictionary[key])
</code></pre>

<p>which works fine but I keep thinking that there's probably a neater way to do it that doesn't involve repeating myself.</p>

<p>Thanks for any suggestions.</p>
