title: Python prime generator in one-line
body: <p>I'm trying to create prime number generator in one-line of Python just as a fun exercise.</p>
  
  <p>The following code works as expected, but it is too slow:</p>
  
  <pre><code>primes = lambda q: (i for i in xrange(1,q) if i not in [j*k for j in xrange(1,i) for k in xrange(1,i)])
  for i in primes(10):
     print i,
  </code></pre>
  
  <p>So I I tried to do it by only checking up to the square-root of j and k:</p>
  
  <pre><code>primes = lambda q: (i for i in xrange(1,q) if i not in [j*k for j in xrange(1,int(round(math.sqrt(i)+1))) for k in xrange(1,int(round(math.sqrt(i)+1)))])
  for i in primes(10):
     print i,
  </code></pre>
  
  <p>But it outputs: <code>2 3 5 6 7 8</code></p>
  
  <p>So there must be something wrong with my indices j and k, but I haven't got a clue.</p>