Re: generator/coroutine terminology

2015-04-18 Thread Albert van der Horst
In article 551e2cfd$0$11123$c3e8...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wednesday 01 April 2015 00:18, Albert van der Horst wrote: In article 55062bda$0$12998$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info

Re: generator/coroutine terminology

2015-04-18 Thread CHIN Dihedral
On Friday, March 13, 2015 at 5:36:35 PM UTC+8, Marko Rauhamaa wrote: Rustom Mody rustompm...@gmail.com: Nice demo of the same confusing terminology we are talking about. Why don't you just stick with the terminology of the language specification? I think your students are going to be more

Re: generator/coroutine terminology

2015-04-03 Thread Steven D'Aprano
On Wednesday 01 April 2015 00:18, Albert van der Horst wrote: In article 55062bda$0$12998$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The biggest difference is syntactic. Here's an iterator which returns a never-ending sequence of squared

Re: generator/coroutine terminology

2015-04-03 Thread Paul Rubin
alb...@spenarnc.xs4all.nl (Albert van der Horst) writes: You should give an example of usage. As a newby I'm not up to figuring out the specification from source for something built of the mysterious __ internal thingies. In reality because of generator expressions, the yield statement, and

Re: generator/coroutine terminology

2015-03-31 Thread Albert van der Horst
In article 83d579c1-ab61-4a3d-a834-e65d28eac...@googlegroups.com, Rustom Mody rustompm...@gmail.com wrote: On Saturday, March 14, 2015 at 8:59:22 PM UTC+5:30, Rustom Mody wrote: On Saturday, March 14, 2015 at 11:34:27 AM UTC+5:30, Steven D'Aprano wrote: A generator (function) may be a

Re: generator/coroutine terminology

2015-03-31 Thread Albert van der Horst
In article mailman.372.1427809109.10327.python-l...@python.org, Dave Angel da...@davea.name wrote: On 03/31/2015 09:18 AM, Albert van der Horst wrote: In article 55062bda$0$12998$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The biggest

Re: generator/coroutine terminology

2015-03-31 Thread Chris Angelico
On Wed, Apr 1, 2015 at 2:03 AM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: class Squares: def __init__(self): self.i = 0 def __next__(self): self.i += 1 return self.i**2 def __iter__(self): return self albert@cherry:/tmp$ python

Re: generator/coroutine terminology

2015-03-31 Thread Albert van der Horst
In article 55062bda$0$12998$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Marko Rauhamaa wrote: Chris Angelico ros...@gmail.com: On Sun, Mar 15, 2015 at 9:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: Is it necessary/useful for a Python

Re: generator/coroutine terminology

2015-03-31 Thread Dave Angel
On 03/31/2015 09:18 AM, Albert van der Horst wrote: In article 55062bda$0$12998$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The biggest difference is syntactic. Here's an iterator which returns a never-ending sequence of squared numbers 1,

Re: generator/coroutine terminology

2015-03-16 Thread Mark Lawrence
On 17/03/2015 03:33, Rustom Mody wrote: On Tuesday, March 17, 2015 at 8:55:27 AM UTC+5:30, Mark Lawrence wrote: On 17/03/2015 03:18, Rustom Mody wrote: On Tuesday, March 17, 2015 at 8:37:25 AM UTC+5:30, Mark Lawrence wrote: Ok Let me throw out a suggestion: - potato is a generator -

Re: generator/coroutine terminology

2015-03-16 Thread Mark Lawrence
On 17/03/2015 02:52, Rustom Mody wrote: On Monday, March 16, 2015 at 11:50:33 PM UTC+5:30, Mark Lawrence wrote: On 16/03/2015 14:37, Rustom Mody wrote: On Monday, March 16, 2015 at 7:57:08 PM UTC+5:30, Mark Lawrence wrote: On 16/03/2015 14:19, Rustom Mody wrote: ==

Re: generator/coroutine terminology

2015-03-16 Thread Rustom Mody
On Tuesday, March 17, 2015 at 8:55:27 AM UTC+5:30, Mark Lawrence wrote: On 17/03/2015 03:18, Rustom Mody wrote: On Tuesday, March 17, 2015 at 8:37:25 AM UTC+5:30, Mark Lawrence wrote: Ok Let me throw out a suggestion: - potato is a generator - tomato is a cursor. Acceptable?

Re: generator/coroutine terminology

2015-03-16 Thread Mario Figueiredo
On Mon, 16 Mar 2015 19:52:59 -0700 (PDT), Rustom Mody rustompm...@gmail.com wrote: When we go from 'simple-generators' to coroutine-generators there seem to be bigger conceptual problems and implementation-gaffes. Quite frankly I hardly understand this part. There's a line after which

Re: generator/coroutine terminology

2015-03-16 Thread Mark Lawrence
On 17/03/2015 03:18, Rustom Mody wrote: On Tuesday, March 17, 2015 at 8:37:25 AM UTC+5:30, Mark Lawrence wrote: Ok Let me throw out a suggestion: - potato is a generator - tomato is a cursor. Acceptable? No. In Python potato is a generator function, tomato is a generator. Why

Re: generator/coroutine terminology

2015-03-16 Thread Rustom Mody
On Monday, March 16, 2015 at 11:50:33 PM UTC+5:30, Mark Lawrence wrote: On 16/03/2015 14:37, Rustom Mody wrote: On Monday, March 16, 2015 at 7:57:08 PM UTC+5:30, Mark Lawrence wrote: On 16/03/2015 14:19, Rustom Mody wrote: == Anyways... Yes 15 years are past. I

Re: generator/coroutine terminology

2015-03-16 Thread Rustom Mody
On Tuesday, March 17, 2015 at 8:37:25 AM UTC+5:30, Mark Lawrence wrote: Ok Let me throw out a suggestion: - potato is a generator - tomato is a cursor. Acceptable? No. In Python potato is a generator function, tomato is a generator. Why complicate something that is so simple?

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
On Tue, 17 Mar 2015 12:13 am, Marko Rauhamaa wrote: If I get an iterator from a black box source, I don't know if I'm allowed/supposed to call close() on it. In no particular order: #1 if hasattr(some_iterator, 'close'): some_iterator.close() #2 close = getattr(some_iterator, 'close',

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Rustom Mody rustompm...@gmail.com: On Monday, March 16, 2015 at 6:02:48 PM UTC+5:30, Marko Rauhamaa wrote: So what we have now is: (1) plain iterators (2) generator iterators (3) coroutine generator iterators (1) and (2) are not unified, which I don't like. Can you expand on that a

Re: generator/coroutine terminology

2015-03-16 Thread Rustom Mody
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

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
On Mon, 16 Mar 2015 11:51 pm, Rustom Mody wrote: It may help to read this 15 year old thread starting https://mail.python.org/pipermail/python-dev/2001-June/015478.html to see how many python stalwarts dont like the current state of affairs /s/dont/didn't/ That's a fifteen year old thread,

Re: generator/coroutine terminology

2015-03-16 Thread Chris Angelico
On Mon, Mar 16, 2015 at 10:51 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Chris Angelico wrote: Just for the record, it's not just name bindings that make a generator behave as a coroutine. E.g.: py def co(): ... print( (yield 1) + 2 ) ... py a = co() py next(a) 1

Re: generator/coroutine terminology

2015-03-16 Thread Jonas Wielicki
On 16.03.2015 13:02, Steven D'Aprano wrote: (To be honest, I'm not even sure what the use-case for close() on coroutines is in the first place. If you don't want to send any more items into it, just don't send any more items into it.) Just like with file-likes, it is useful to clean up

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
Marko Rauhamaa wrote: Anyway, calling close() on an iterator can be a necessary requirement even in ordinary generator usage. Only now they have to know if the underlying iterator was sired by a generator or some other constructor. Can you give an actual example of that? (To be honest, I'm

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: (To be honest, I'm not even sure what the use-case for close() on coroutines is in the first place. If you don't want to send any more items into it, just don't send any more items into it.) Without close(), you might leave resources

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
Marko Rauhamaa wrote: Chris Angelico ros...@gmail.com: On Mon, Mar 16, 2015 at 6:12 PM, Marko Rauhamaa ma...@pacujo.net wrote: I was actually referring to the offered API. It still seems to me like all iterators could offer close(), send() and throw(). Why? To make all iterators drop-in

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
Chris Angelico wrote: On Mon, Mar 16, 2015 at 7:36 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I expect that the interpreter can tell the difference between yield spam and x = yield spam and only allow send(), close() and throw() on generators which include

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: If I .send() into either of the generators above, its a conceptual mistake and I should get an error. The fact that I don't is an implementation detail, and one which hopefully will be fixed. So what we have now is: (1) plain iterators

Re: generator/coroutine terminology

2015-03-16 Thread Rustom Mody
On Monday, March 16, 2015 at 6:02:48 PM UTC+5:30, Marko Rauhamaa wrote: So what we have now is: (1) plain iterators (2) generator iterators (3) coroutine generator iterators (1) and (2) are not unified, which I don't like. Can you expand on that a bit? It may help to read

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: Or inversely I write a normal utility function that is called from coroutines, then later add a yield from to it, and now I have to go back and revise every place where it's called to make those use yield from as well. That is actually quite awkward. Smooth

Re: generator/coroutine terminology

2015-03-16 Thread Rustom Mody
On Monday, March 16, 2015 at 8:07:22 PM UTC+5:30, Rustom Mody wrote: I would gladly do that if it was a minor correction here and there. But the problem is a bit deeper even though it can be kept mostly¹ in the docs and not modify any syntax/semantics of python. In particular for: def

Re: generator/coroutine terminology

2015-03-16 Thread Ian Kelly
On Mon, Mar 16, 2015 at 9:09 AM, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: For generators, the descriptive keyword (yield) could be buried *anywhere* in that block. One can glance at a generator function and fail to notice that it is a generator function. This is

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
On Tue, 17 Mar 2015 01:35 am, Steven D'Aprano wrote: 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.

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
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

Re: generator/coroutine terminology

2015-03-16 Thread Ian Kelly
On Mon, Mar 16, 2015 at 8:32 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 17 Mar 2015 12:13 am, Marko Rauhamaa wrote: If I get an iterator from a black box source, I don't know if I'm allowed/supposed to call close() on it. In no particular order: #1 if

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: For generators, the descriptive keyword (yield) could be buried *anywhere* in that block. One can glance at a generator function and fail to notice that it is a generator function. This is the one that really bugs me about reuse of def, although you are

Re: generator/coroutine terminology

2015-03-16 Thread Ian Kelly
On Mon, Mar 16, 2015 at 7:39 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 16 Mar 2015 11:51 pm, Rustom Mody wrote: It may help to read this 15 year old thread starting https://mail.python.org/pipermail/python-dev/2001-June/015478.html to see how many python

Re: generator/coroutine terminology

2015-03-16 Thread Mark Lawrence
On 16/03/2015 14:19, 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

Re: generator/coroutine terminology

2015-03-16 Thread Rustom Mody
On Monday, March 16, 2015 at 7:57:08 PM UTC+5:30, Mark Lawrence wrote: On 16/03/2015 14:19, Rustom Mody wrote: == Anyways... Yes 15 years are past. I dont expect the def can be revoked now. [As far as I am concerned its a minor wart] But the mess around the docs

Re: generator/coroutine terminology

2015-03-16 Thread Ian Kelly
On Mon, Mar 16, 2015 at 1:12 AM, Marko Rauhamaa ma...@pacujo.net wrote: I was actually referring to the offered API. It still seems to me like all iterators could offer close(), send() and throw(). Why? To make all iterators drop-in replacements of each other. The purpose of close, send and

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: What features do generator iterators provide on top of generic iterators? The biggest difference is syntactic. Here's an iterator which returns a never-ending sequence of squared numbers 1, 4, 9, 16, ... class

Re: generator/coroutine terminology

2015-03-16 Thread Chris Angelico
On Mon, Mar 16, 2015 at 6:12 PM, Marko Rauhamaa ma...@pacujo.net wrote: I was actually referring to the offered API. It still seems to me like all iterators could offer close(), send() and throw(). Why? To make all iterators drop-in replacements of each other. Then, you could also stop

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: On Mon, Mar 16, 2015 at 6:12 PM, Marko Rauhamaa ma...@pacujo.net wrote: I was actually referring to the offered API. It still seems to me like all iterators could offer close(), send() and throw(). Why? To make all iterators drop-in replacements of each

Re: generator/coroutine terminology

2015-03-16 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: If on the other hand these methods were to be added to the iterator protocol, it would just create unnecessary implementation overhead for the 99.99% of non-generator iterators that are under no illusions about the fact that they aren't coroutines. Why should

Re: generator/coroutine terminology

2015-03-16 Thread Mark Lawrence
On 16/03/2015 14:37, Rustom Mody wrote: On Monday, March 16, 2015 at 7:57:08 PM UTC+5:30, Mark Lawrence wrote: On 16/03/2015 14:19, Rustom Mody wrote: == Anyways... Yes 15 years are past. I dont expect the def can be revoked now. [As far as I am concerned its a minor wart]

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
On Monday 16 March 2015 18:12, Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: What features do generator iterators provide on top of generic iterators? The biggest difference is syntactic. Here's an iterator which returns a never-ending

Re: generator/coroutine terminology

2015-03-16 Thread Chris Angelico
On Mon, Mar 16, 2015 at 7:36 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I expect that the interpreter can tell the difference between yield spam and x = yield spam and only allow send(), close() and throw() on generators which include the second form. If it

Re: generator/coroutine terminology

2015-03-15 Thread Steven D'Aprano
Rustom Mody wrote: On Saturday, March 14, 2015 at 11:34:27 AM UTC+5:30, Steven D'Aprano wrote: A generator (function) may be a function which returns an iterator,... I find generator-function misleading in the same way that pineapple misleadingly suggests apple that grows on pines You

Re: generator/coroutine terminology

2015-03-15 Thread Steven D'Aprano
Marko Rauhamaa wrote: Chris Angelico ros...@gmail.com: On Sun, Mar 15, 2015 at 9:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: Is it necessary/useful for a Python application programmer to be conscious of the different types of iterator? What mistaken usage could arise if the application

Re: generator/coroutine terminology

2015-03-14 Thread Mark Lawrence
On 14/03/2015 20:14, Ian Kelly wrote: Now which should be considered definitive, the language reference or the PEP? This question is not rhetorical; I don't know the answer. Regardless of the answer though, the PEP at least illuminates the design intent of the terminology. The language

Re: generator/coroutine terminology

2015-03-14 Thread Marko Rauhamaa
Oscar Benjamin oscar.j.benja...@gmail.com: A generator is a special type of iterator that results from generator functions and generator expressions. Is it necessary/useful for a Python application programmer to be conscious of the different types of iterator? What mistaken usage could arise

Re: generator/coroutine terminology

2015-03-14 Thread Oscar Benjamin
On 12 March 2015 at 16:52, Rustom Mody rustompm...@gmail.com wrote: On Thursday, March 12, 2015 at 9:58:07 PM UTC+5:30, Steven D'Aprano wrote: Rustom Mody wrote: Say I have a simple yielding function: def foo(x): yield x+1 yield x+2 And I have g = foo(2) If I look

Re: generator/coroutine terminology

2015-03-14 Thread Chris Angelico
On Sun, Mar 15, 2015 at 9:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: Oscar Benjamin oscar.j.benja...@gmail.com: A generator is a special type of iterator that results from generator functions and generator expressions. Is it necessary/useful for a Python application programmer to be

Re: generator/coroutine terminology

2015-03-14 Thread Chris Angelico
On Sun, Mar 15, 2015 at 11:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: On Sun, Mar 15, 2015 at 11:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: What features do generator iterators provide on top of generic iterators? You can send values into them, throw

Re: generator/coroutine terminology

2015-03-14 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: On Sun, Mar 15, 2015 at 11:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: What features do generator iterators provide on top of generic iterators? You can send values into them, throw exceptions into them, and close them (which is a special case of the

Re: generator/coroutine terminology

2015-03-14 Thread Chris Angelico
On Sun, Mar 15, 2015 at 11:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: On Sun, Mar 15, 2015 at 9:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: Is it necessary/useful for a Python application programmer to be conscious of the different types of iterator? What

Re: generator/coroutine terminology

2015-03-14 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: On Sun, Mar 15, 2015 at 9:15 AM, Marko Rauhamaa ma...@pacujo.net wrote: Is it necessary/useful for a Python application programmer to be conscious of the different types of iterator? What mistaken usage could arise if the application just treated all iterators

Re: generator/coroutine terminology

2015-03-14 Thread Ian Kelly
On Sat, Mar 14, 2015 at 1:54 AM, Marko Rauhamaa ma...@pacujo.net wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: Your 'factory' is a: generator A function which returns an iterator. URL: https://docs.python.org/3/glossary.html That

Re: generator/coroutine terminology

2015-03-14 Thread Rustom Mody
On Sunday, March 15, 2015 at 1:45:37 AM UTC+5:30, Ian wrote: Now which should be considered definitive, the language reference or the PEP? This question is not rhetorical; I don't know the answer. Regardless of the answer though, the PEP at least illuminates the design intent of the

Re: generator/coroutine terminology

2015-03-14 Thread Steven D'Aprano
Marko Rauhamaa wrote: Your 'factory' is a: generator A function which returns an iterator. URL: https://docs.python.org/3/glossary.html That glossary entry is misleading, or at least incomplete, and it fails to match the way generator is used by actual Python programmers.

Re: generator/coroutine terminology

2015-03-14 Thread Mark Lawrence
On 14/03/2015 07:54, Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: Your 'factory' is a: generator A function which returns an iterator. URL: https://docs.python.org/3/glossary.html That glossary entry is misleading, or

Re: generator/coroutine terminology

2015-03-14 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: Marko Rauhamaa wrote: Your 'factory' is a: generator A function which returns an iterator. URL: https://docs.python.org/3/glossary.html That glossary entry is misleading, or at least incomplete, and it fails to match

Re: generator/coroutine terminology

2015-03-14 Thread Marko Rauhamaa
Mark Lawrence breamore...@yahoo.co.uk: On 14/03/2015 07:54, Marko Rauhamaa wrote: I am an actual Python programmer (I develop Python programs) and my definitive source for Python is the documentation. If there is an error in the documentation, I would very much like it to be corrected.

Re: generator/coroutine terminology

2015-03-14 Thread Dave Angel
On 03/14/2015 12:51 PM, Chris Angelico wrote: On Sun, Mar 15, 2015 at 3:33 AM, Rustom Mody rustompm...@gmail.com wrote: As best as I can see python makes no distinction between such a foo and the more usual function/methods that have no returns. You can I can talk about these and distinguish

Re: generator/coroutine terminology

2015-03-14 Thread Rustom Mody
On Saturday, March 14, 2015 at 10:22:51 PM UTC+5:30, Chris Angelico wrote: On Sun, Mar 15, 2015 at 3:33 AM, Rustom Mody wrote: As best as I can see python makes no distinction between such a foo and the more usual function/methods that have no returns. You can I can talk about these and

Re: generator/coroutine terminology

2015-03-14 Thread Rustom Mody
On Saturday, March 14, 2015 at 9:45:10 PM UTC+5:30, Chris Angelico wrote: On Sun, Mar 15, 2015 at 2:59 AM, Rustom Mody wrote: Causing all sorts of unnecessary confusions: An int-function returns int and a char*-functions returns char*. Does a void-function return void?? No a void function

Re: generator/coroutine terminology

2015-03-14 Thread Chris Angelico
On Sun, Mar 15, 2015 at 3:33 AM, Rustom Mody rustompm...@gmail.com wrote: As best as I can see python makes no distinction between such a foo and the more usual function/methods that have no returns. You can I can talk about these and distinguish them Python has no clue about it. But what

Re: generator/coroutine terminology

2015-03-14 Thread Mark Lawrence
On 14/03/2015 16:33, Rustom Mody wrote: On Saturday, March 14, 2015 at 9:45:10 PM UTC+5:30, Chris Angelico wrote: On Sun, Mar 15, 2015 at 2:59 AM, Rustom Mody wrote: Causing all sorts of unnecessary confusions: An int-function returns int and a char*-functions returns char*. Does a

Re: generator/coroutine terminology

2015-03-14 Thread Rustom Mody
On Saturday, March 14, 2015 at 11:34:27 AM UTC+5:30, Steven D'Aprano wrote: A generator (function) may be a function which returns an iterator,... I find generator-function misleading in the same way that pineapple misleadingly suggests apple that grows on pines A builtin function is a

Re: generator/coroutine terminology

2015-03-14 Thread Chris Angelico
On Sun, Mar 15, 2015 at 2:29 AM, Rustom Mody rustompm...@gmail.com wrote: However a generator function is a weird sort of function (at best). Not regarding it as a function is IMO more reasonable. But it *is* a function. You call it, possibly with positional and/or keyword arguments, and you

Re: generator/coroutine terminology

2015-03-14 Thread Rustom Mody
On Saturday, March 14, 2015 at 8:59:22 PM UTC+5:30, Rustom Mody wrote: On Saturday, March 14, 2015 at 11:34:27 AM UTC+5:30, Steven D'Aprano wrote: A generator (function) may be a function which returns an iterator,... I find generator-function misleading in the same way that pineapple

Re: generator/coroutine terminology

2015-03-14 Thread Chris Angelico
On Sun, Mar 15, 2015 at 2:59 AM, Rustom Mody rustompm...@gmail.com wrote: Causing all sorts of unnecessary confusions: An int-function returns int and a char*-functions returns char*. Does a void-function return void?? No a void function doesn't return anything! Ah So a void function does a

Re: generator/coroutine terminology

2015-03-13 Thread Rustom Mody
On Friday, March 13, 2015 at 1:53:50 PM UTC+5:30, Chris Angelico wrote: On Fri, Mar 13, 2015 at 4:28 PM, Rustom Mody wrote: And even there I would expect generators to close with StopIteration Whereas I would expect coroutines to close (on close method) with GeneratorExit [Ive not

Re: generator/coroutine terminology

2015-03-13 Thread Marko Rauhamaa
Rustom Mody rustompm...@gmail.com: Nice demo of the same confusing terminology we are talking about. Why don't you just stick with the terminology of the language specification? I think your students are going to be more confused if you try to come up with something better. When I say expect

Re: generator/coroutine terminology

2015-03-13 Thread Chris Angelico
On Fri, Mar 13, 2015 at 4:28 PM, Rustom Mody rustompm...@gmail.com wrote: And even there I would expect generators to close with StopIteration Whereas I would expect coroutines to close (on close method) with GeneratorExit [Ive not thought all this through properly so may be off the mark] I

Re: generator/coroutine terminology

2015-03-13 Thread Chris Angelico
On Fri, Mar 13, 2015 at 8:12 PM, Rustom Mody rustompm...@gmail.com wrote: On Friday, March 13, 2015 at 1:53:50 PM UTC+5:30, Chris Angelico wrote: On Fri, Mar 13, 2015 at 4:28 PM, Rustom Mody wrote: And even there I would expect generators to close with StopIteration Whereas I would expect

generator/coroutine terminology

2015-03-12 Thread Rustom Mody
This is more a question about standard terminology/conventions than about semantics - of course assuming I understand :-) Say I have a simple yielding function: def foo(x): yield x+1 yield x+2 And I have g = foo(2) If I look at type, g's type is 'generator' whereas foo is just plain-ol

Re: generator/coroutine terminology

2015-03-12 Thread Chris Angelico
On Fri, Mar 13, 2015 at 12:35 AM, Rustom Mody rustompm...@gmail.com wrote: If I look at type, g's type is 'generator' whereas foo is just plain-ol 'function.' Whereas in informal usage we say foo is a generator. So the question: What should we call foo and what should we call g? g is a

Re: generator/coroutine terminology

2015-03-12 Thread breamoreboy
On Thursday, March 12, 2015 at 1:35:48 PM UTC, Rustom Mody wrote: This is more a question about standard terminology/conventions than about semantics - of course assuming I understand :-) Say I have a simple yielding function: def foo(x): yield x+1 yield x+2 And I have g =

Re: generator/coroutine terminology

2015-03-12 Thread Rustom Mody
On Friday, March 13, 2015 at 9:00:17 AM UTC+5:30, Steven D'Aprano wrote: Rustom Mody wrote: On Thursday, March 12, 2015 at 11:25:32 PM UTC+5:30, Marko Rauhamaa wrote: Rustom Mody : I guess we need 1. A clear ontology of the base concepts (which is a buzzword for nailed-down

Re: generator/coroutine terminology

2015-03-12 Thread Steven D'Aprano
Rustom Mody wrote: On Thursday, March 12, 2015 at 11:25:32 PM UTC+5:30, Marko Rauhamaa wrote: Rustom Mody : I guess we need 1. A clear ontology of the base concepts (which is a buzzword for nailed-down terminology) According to the documentation, a function whose definition contains

Re: generator/coroutine terminology

2015-03-12 Thread Rustom Mody
On Thursday, March 12, 2015 at 11:25:32 PM UTC+5:30, Marko Rauhamaa wrote: Rustom Mody : I guess we need 1. A clear ontology of the base concepts (which is a buzzword for nailed-down terminology) According to the documentation, a function whose definition contains a yield statement is

Re: generator/coroutine terminology

2015-03-12 Thread Steven D'Aprano
Rustom Mody wrote: This is more a question about standard terminology/conventions than about semantics - of course assuming I understand :-) Say I have a simple yielding function: def foo(x): yield x+1 yield x+2 And I have g = foo(2) If I look at type, g's type is

Re: generator/coroutine terminology

2015-03-12 Thread Rustom Mody
Guess I should be pleased that I am doing as good as you (and Chris) describe. For some reason or not I am not... On Thursday, March 12, 2015 at 9:58:07 PM UTC+5:30, Steven D'Aprano wrote: Rustom Mody wrote: This is more a question about standard terminology/conventions than about

Re: generator/coroutine terminology

2015-03-12 Thread Marko Rauhamaa
Terry Reedy tjre...@udel.edu: On 3/12/2015 9:35 AM, Rustom Mody wrote: This is more a question about standard terminology/conventions than about semantics - of course assuming I understand :-) Say I have a simple yielding function: def foo(x): yield x+1 yield x+2 This is a

Re: generator/coroutine terminology

2015-03-12 Thread Terry Reedy
On 3/12/2015 9:35 AM, Rustom Mody wrote: This is more a question about standard terminology/conventions than about semantics - of course assuming I understand :-) Say I have a simple yielding function: def foo(x): yield x+1 yield x+2 This is a generator function And I have g =

Re: generator/coroutine terminology

2015-03-12 Thread Marko Rauhamaa
Rustom Mody rustompm...@gmail.com: I guess we need 1. A clear ontology of the base concepts (which is a buzzword for nailed-down terminology) According to the documentation, a function whose definition contains a yield statement is a generator: Using a yield expression in a function’s