[Python-ideas] More general "for" loop handling

Paul Moore p.f.moore at gmail.com
Thu Apr 30 12:00:28 CEST 2015


On 30 April 2015 at 10:48, Todd <toddrjen at gmail.com> wrote:
> Of course this sort of thing is possible with iterators and maps today, but
> I think a lot of the same advantages that apply to asyncio also apply to
> these sorts of cases.  So I think that, rather than having a special keyword
> just for asyncio, I think it would be better to have a more flexible
> approach.  Perhaps something like a "__for__" magic method that lets a class
> implement "for" loop handling, along with the corresponding changes in how
> the language processes the "for" loop.

+1 on making a more general construct than "async for", which can then
be used to implement an equivalent to "async for" as well as similar
constructs for threads processes and whatever else 3rd party code
might find a use for.

Paul


More information about the Python-ideas mailing list