About that 'yield' word

Lulu of the Lotus-Eaters mertz at gnosis.cx
Sat Oct 4 22:25:32 EDT 2003


|Tobiah wrote:
|> > def maker():
|> >     for i in range(100):
|> >         yield i

David Eppstein <eppstein at ics.uci.edu> wrote previously:
|I guess this was just thrown together as an example of "yield", rather
|than real code, but:
|def maker():
|    return range(100)

And less contorted still is:

    xrange(100)

:-).

--
Keeping medicines from the bloodstreams of the sick; food from the bellies
of the hungry; books from the hands of the uneducated; technology from the
underdeveloped; and putting advocates of freedom in prisons.  Intellectual
property is to the 21st century what the slave trade was to the 16th.





More information about the Python-list mailing list