the usage of 'yield' keyword

P

Paul Rudin

Peng Yu said:
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

Try the sections on iterators, generators and generator expressions in
the tutorial: <http://docs.python.org/tutorial/classes.html#iterators>
 
S

Sean DiZazzo

What do you think about that Peng?!?

Please share your thoughts, as this list is a learning experience for
everyone involved. We can learn from your thoughts/experiences as
well.

Cheers and well being,

~Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top