the usage of 'yield' keyword

Sean DiZazzo half.italian at gmail.com
Fri Oct 16 06:48:10 CEST 2009


On Oct 13, 6:41 pm, Peng Yu <pengyu... at gmail.com> wrote:
> http://docs.python.org/reference/simple_stmts.html#grammar-token-yiel...
>
> The explanation of yield is not clear to me, as I don't know what a
> generator is. I see the following example using 'yield'. Could
> somebody explain how 'yield' works in this example? Thank you!
>
> def brange(limit):
>   i = 0
>   while i < limit:
>       yield i
>       i += 1

What do you think about that Peng?!?



More information about the Python-list mailing list