I’m simply blown away by this. Check out this piece of code (if you care to) —-
def factors(num): i = 2 yield 1 while i<((num/2)+1): if num%i == 0: yield i i = i+1 if __name__ == "__main__": f = factors(12321) for i in f: print i,
Which gives you the output —
1 3 9 37 111 333 1369 4107
Generators are similar to functions, but they remember their state. And you can iterate over a generator’s output. I can already think of so many ways in which this is cool. The language is Python of course.