title: python why lambda behaves differently when it has constant compare to calls random function
body: <p>I probably don't understand python's lambda very much. So it confuses me evry time. For example if I have this simple lambda construction with constant, everything works perfect:</p>
  
  <pre><code>&gt;&gt;&gt; f = lambda max,x=0:[ x for x in iter(lambda: x+0.5,max+1.) if x&lt;max ]
  &gt;&gt;&gt; f(10)
  [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5]
  </code></pre>
  
  <p>But if I substitute  random number generator instead of constant 0.5, it would stuck and never returns back....</p>
  
  <pre><code>&gt;&gt;&gt; f = lambda max,x=0:[ x for x in iter(lambda: x+random.random(),max+1.) if x&lt;max ]
  &gt;&gt;&gt; f(10)
  </code></pre>
  
  <p>Why?! And what to do to avoid it?</p>