Feb. 21, 2014
10:33 p.m.
Nick Coghlan wrote:
isprime = all(n % p for p in takewhile((: ? ** 2 < n), primes_seen))
-1, this is far too cryptic and ugly to have a place in Python. I'd be +0 on adding a while clause to for-loops, in *both* comprehension and statement forms, so that the above could be written isprime = all(n % p for p in primes_seen while p ** 2 < n) Adding a corresponding clause to the for-statement would allow the semantic definition of list comprehensions in terms of the statement expansion to be preserved. However, this all hinges on whether there is enough use for the feature to be worth adding. I'm yet to be convinced of that. -- Greg