[Python-ideas] Decorators on loops

Enric Tejedor enric.tejedor at bsc.es
Wed Jan 8 12:21:31 CET 2014


Hello,

I would like to discuss a new use of python decorators. I apologize if
this has already been suggested before.

The basic idea would be to support decorators on loops, in addition to
functions and classes. Something like this:

@mydecorator
for i in range(10):
     # loop body

In mydecorator, I would like to have access to the loop body and the
iterable object.

In my case, I would use this to parallelize the iterations of the loop.


Thank you for your feedback,


Enric

WARNING / LEGAL TEXT: This message is intended only for the use of the
individual or entity to which it is addressed and may contain
information which is privileged, confidential, proprietary, or exempt
from disclosure under applicable law. If you are not the intended
recipient or the person responsible for delivering the message to the
intended recipient, you are strictly prohibited from disclosing,
distributing, copying, or in any way using this message. If you have
received this communication in error, please notify the sender and
destroy and delete any copies you may have received.

http://www.bsc.es/disclaimer


More information about the Python-ideas mailing list