Generators in Python

One of the few obscure feature of python (for the beginners) is Generators. In this post I would like to share few naive questions I had about generators and the answers I got after understanding them.

Question 1: Are generators something like static variables in C? Say, generateFibonacciNumber() is a generator. First time I call generateFibonacciNumber() and iterate upto value 5, the next time I call generateFibonacciNumber() will it start returning from value 8 when iterated?

This could sound like most dumb question on earth, but honestly I had this question having come from C background.

Answer: No. Generators should ...

View comments.

more ...