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

Yury Selivanov yselivanov.ml at gmail.com
Thu Apr 30 18:58:41 CEST 2015



On 2015-04-30 5:48 AM, Todd wrote:
> For example, you could create a multiprocessing pool, and let the pool
> handle the items in a "for" loop, like so:
>
>      from multiprocessing import Pool
>
>      mypool = Pool(10, maxtasksperchild=2)
>
>      mypool for item in items:


This looks "OK" for a simple snippet, but how will you define
this new syntax in Python grammar?

Unless you restrict such syntax to use only NAME tokens before
'for', you can easily expect users to write code like this:

    some_namespace.module.function(arg=123) for item in items():
        ...

Yury


More information about the Python-ideas mailing list