Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: yield

Reply
Thread Tools

Re: yield

 
 
km
Guest
Posts: n/a
 
      01-17-2004
Hi gerrit,

i ran the snippet but i am sorry, i couldnt get what u were saying.
kindly enlighten,
regards,
KM

---------------------------------------------------------------------
On Sat, Jan 17, 2004 at 05:59:21PM +0100, Gerrit Holl wrote:
> > i didnt understand the purpose of 'yield' keyword and the concept of 'generators' in python. can someone explain me with a small example how generators differ from normal function calls?
> > kindly enlighten

>
> You can see 'yield' as a continuable function:
>
> def f():
> yield time.time()
> yield time.time()
> yield time.time()
>
> now f() will return a generator, with a .next() method. Try:
> g = f()
> g.next()
> g.next()
> g.next()
>
> on the interactive prompt, and see what happens...
>
> yours,
> Gerrit.
>
> --
> Mozilla _is_ the web: it grows faster than you can download it.
> 1011001 1101111 1110101 1110010 1110011 0101100
> 1000111 1100101 1110010 1110010 1101001 1110100


--





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] To Yield or Not to Yield: An Inferable Question Michael Edgar Ruby 13 04-21-2011 05:55 PM
yield expression programmized-formal interpretation. (interpretationof yield expression.) castironpi@gmail.com Python 1 04-22-2008 01:32 AM
Yield & associations (was Proc / def /yield semantics) Markus Ruby 1 09-27-2004 07:04 PM
Don't really understand Thread.yield() qjzhu Java 3 10-13-2003 07:06 PM
Make thread Yield and sleep at the same time Rick Java 2 10-04-2003 08:22 PM



Advertisments