On Tue, 17 Mar 2015 01:19 am, Rustom Mody wrote:

> On Monday, March 16, 2015 at 7:10:03 PM UTC+5:30, Steven D'Aprano wrote:
>> And of course, from a comp science theoretic perspective,
>> generators are a kind of subroutine, not a kind of type.
> 
> You just showed Marko a few posts back, that
> A generator is a special case of an iterator.
> And you wrote the iterator with 'class'.
> And from python 2.2(?) classes are types.

Yes, but iterators aren't *classes*, they are instances.


> So I dont know what "comp science theoretic perspective" you are
> describing...

http://en.wikipedia.org/wiki/Generator_(computer_programming)

"A generator is very similar to a function that returns an array, in that a
generator has parameters, can be called, and generates a sequence of
values. However, instead of building an array containing all the values and
returning them all at once, a generator yields the values one at a time,
which requires less memory and allows the caller to get started processing
the first few values immediately. In short, a generator looks like a
function but behaves like an iterator."





-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to