steve at ninereeds.fsnet.co.uk
Mon Mar 22 20:34:35 CET 2004
On Mon, 22 Mar 2004 08:43:08 -0800, David Eppstein
<eppstein at ics.uci.edu> wrote:
>In article <7xn069t5pr.fsf at ruckus.brouhaha.com>,
> Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>> Eyal Lotem <gnupeaker at yahoo.com> writes:
>> > You are not supposed to be looking for it, IMHO.
>> > Generators follow the Sequence protocol and are to be
>> > treated as sequences. Thus, you should simply make it
>> But that's bogus. Python is dynamically typed which means that a
>> normal function can return whatever it wants, sequence or
>> non-sequence. A generator function can't return anything, it can only
>I agree with Eyal. A generator is a callable that, when called, returns
>an iterator of the items it generates. The fact that it's defined using
>yield syntax instead of using return syntax is irrelevant to the caller.
I agree, but I'd still prefer it if the difference between a generator
and a function was explicit in the definition.
steve at ninereeds dot fsnet dot co dot uk
More information about the Python-list