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

Todd toddrjen at gmail.com
Thu Apr 30 19:07:34 CEST 2015


On Thu, Apr 30, 2015 at 6:58 PM, Yury Selivanov <yselivanov.ml at gmail.com>
wrote:

>
>
> 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():
>        ...
>

pep8, probably.  You can write ugly code now.  This isn't much better:

    some_namespace.module.function(arg=123).map(items())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150430/5d8e89b1/attachment-0001.html>


More information about the Python-ideas mailing list