[Python-ideas] adding an __exec__ method to context managers?
sturla at molden.no
Tue Oct 13 17:57:08 CEST 2009
Ryan Freckleton skrev:
> # The function dostuff_in_parallel is called when necessary by the
> pymp object.
> def dostuff_in_parallel(mt):
> with mt.critical:
I am beginning to feel a little stupid. :-(
Right... a decorator would always be called for a closure, not just once
on module import. So I could make function "def parallel_for(iterable)"
return a decorator and auto-execute the closure. That would indeed give
cleaner decorator syntax instead of calling the decorated closure manually.
More information about the Python-ideas