I don't really disagree with most of what you wrote! And agree that decorators, 
specifically, are a pretty good solution within the scope of an individual 
package.

But I would quibble with this:

>How fundamental is it that THIS function is a generator, rather than simply 
>that
> it returns an iterator (or that it returns a generator/coroutine object, etc)?

The delayed execution of a generator function is, IMO very, very different than 
a regular function!

```
def f():
    result = side_effect1()
    yield 0
    yield 1
    return result
```

vs.

```
def f():
   side_effect()
   return range(2)
```

These are contrived examples, obviously, but I've specifically encountered 
issues like this when working with code that handles streaming data - from a db 
or REST API, for instance. My experience of this type of code is often along 
the following lines:

```
def stream_rows(self):
   [mutex handling ...]
       [retry logic]
           [more mutexes?]
               [some timeout stuff]
                   [...]
```

I don't mean to belabor the point - the decision in PEP 255 is pretty 
definitive, and this was more or less a "modest proposal" anyway. I do 
appreciate the responses and discussion!

Thanks,
Aaron
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JMAWFCPYBW5BN2C33KNBE563YHRZZPXG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to