the usage of 'yield' keyword

Javier Collado javier.collado at gmail.com
Wed Oct 14 09:46:49 CEST 2009


Hello,

I think that the best information available on the subject is the following:
http://www.dabeaz.com/generators/
http://www.dabeaz.com/coroutines/

Best regards,
    Javier

2009/10/14 Peng Yu <pengyu.ut at gmail.com>:
> http://docs.python.org/reference/simple_stmts.html#grammar-token-yield_stmt
>
> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list