Python max-by function?
<p>Example:</p>

<pre><code>print max(chain_length(i) for i in xrange(1,10001))
</code></pre>

<p>This returns the maximum/biggest "chain_length" (an arbitrary function), but what I want is the <code>i</code> value for input that produces the biggest value.</p>

<p>Is there a convenient way to do that?</p>
