[Python-ideas] keyword for introducing generators

Guido van Rossum guido at python.org
Sun Aug 17 01:42:36 CEST 2014


On Sat, Aug 16, 2014 at 3:17 PM, Jonas Wielicki <j.wielicki at sotecware.net>
wrote:

> On 16.08.2014 23:46, Neil Girdhar wrote:
> > I'm sure this has been suggested before, but I just spent two days trying
> > to figure out why a method wasn't being called only to find that I'd
> > accidentally pasted a yield into the function.  What is the argument
> > against a different keyword for introducing generator functions/methods?
> >
> > If it's backward compatibility, then my suggestion to have a from
> > __future__ and then make it real in Python 4.
>
> For what it’s worth, I know this problem very well, and it can take
> hours to figure out whats wrong.
>

A linter should be able to figure this out. For example, mypy will insist
that a generator has a return type of Iterable[...]. So maybe you won't
have to wait for Python 4; if the mypy proposal goes forward you will be
able to use type annotations to distinguish generators.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140816/c8b8a747/attachment.html>


More information about the Python-ideas mailing list