gen1 = (ord(c) for c in 'CS 340!') def allprimes(): """This uses the ancient algorithm known as the Sieve of Eratosthenes""" yield 2 found = [2] next = 3 while True: cap = next**0.5 for p in found: if p > cap: yield next found.append(next) break if (next % p) == 0: break next += 2 gen2 = allprimes() print(gen1, gen2) print(next(gen1), next(gen2)) print(next(gen1), next(gen2)) for codepoint in gen1: print(codepoint,'came from',repr(chr(codepoint))) for p in gen2: print(p,'is prime')