Re: [Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-29 Thread Stephen J. Turnbull
Steven D'Aprano writes: > > The two iterators have the same duck-type, the generator is different. > > How is the generator different? My bad, I got the comparison backward. The generator *is* different, but it's because the generator has *extra* public methods, not fewer. Sorry for the noi

Re: [Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-28 Thread Steven D'Aprano
On Tue, Nov 28, 2017 at 04:25:23PM +, Rob Cliffe wrote: > Given that we have this kind of arcane discussion fairly regularly (not > just in this thread), and it always makes my head spin, and it seems I'm > not the only one who gets confused: > > How about having a module that provides func

Re: [Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-28 Thread Rob Cliffe
Given that we have this kind of arcane discussion fairly regularly (not just in this thread), and it always makes my head spin, and it seems I'm not the only one who gets confused: How about having a module that provides functions such as     isgenerator  isiterator  isiterable  etc. or alter

Re: [Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-28 Thread Nick Coghlan
On 28 November 2017 at 16:11, Stephen J. Turnbull wrote: > Steven D'Aprano writes: > > > The subset of iterators which are created as generators are *also* > > called generators, > > As long as we're being precise, I don't think that is precisely correct: > > >>> (x for x in range(1)) >

Re: [Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-27 Thread Steven D'Aprano
On Tue, Nov 28, 2017 at 03:11:25PM +0900, Stephen J. Turnbull wrote: > Steven D'Aprano writes: > > > The subset of iterators which are created as generators are *also* > > called generators, > > As long as we're being precise, I don't think that is precisely correct: > > >>> (x for x in r

Re: [Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-27 Thread Stephen J. Turnbull
Steven D'Aprano writes: > The subset of iterators which are created as generators are *also* > called generators, As long as we're being precise, I don't think that is precisely correct: >>> (x for x in range(1)) at 0x10dee5e08> >>> iter(range(1)) >>> iter((1,)) Th

Re: [Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-27 Thread Steven D'Aprano
On Mon, Nov 27, 2017 at 06:35:38PM +0200, Koos Zevenhoven wrote: > SOLUTION: Maybe (a) all iterators should be called iterators All iterators *are* called iterators. Just as all mammals are called "mammals". The subset of iterators which are created as generators are *also* called generators,

[Python-ideas] generator vs iterator etc. (was: How assignment should work with generators?)

2017-11-27 Thread Koos Zevenhoven
On Mon, Nov 27, 2017 at 3:55 PM, Steven D'Aprano wrote: > On Mon, Nov 27, 2017 at 12:17:31PM +0300, Kirill Balunov wrote: > ​​ > > > 2. Should this work only for generators or for any iterators? > > I don't understand why you are even considering singling out *only* > generators. A generator is