[Python-ideas] keyword for introducing generators

Neil Girdhar mistersheik at gmail.com
Sat Sep 20 17:50:21 CEST 2014


Sorry for the late reply. If I mark a function as returning Iterable, the
linter can check that I use yield in the function, but if I don't mark the
function as returning anything, the linter should also check that I didn't
accidentally use yield, which is the time-consuming bug that we're talking
about.  So this works for me.

Best,

Neil

On Sat, Aug 16, 2014 at 7:42 PM, Guido van Rossum <guido at python.org> wrote:

> 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)
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/5-Qm2od4xQ8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140920/14a9884e/attachment.html>


More information about the Python-ideas mailing list