from functools import reduce
reduce(lambda r, x: r.difference_update(list(range(x * x, N, 2 * x))) or r if x in
    r else r, list(range(3, int((N + 1) ** 0.5 + 1), 2)), set([2] + list(range(3, N, 2))))
Python prime generator in one-line