[Python-ideas] Anonymous blocks (again):
Juancarlo Añez
apalala at gmail.com
Sun May 12 13:56:40 CEST 2013
On Sun, May 12, 2013 at 3:48 AM, Devin Jeanpierre <jeanpierreda at gmail.com>wrote:
> the code would be closure(block)()).
>
> Consider:
>
> >>> def closure(f):
> ... f(); f(); f()
> ...
> >>> @closure
> ... def block():
> ... print "Hi"
> ...
> Hi
> Hi
> Hi
>
Mmm. Interesting, but unpythonic.
A decorator that executes the target right away?
I also tried:
with closure:
while True:
block
But the context-manager design is shortsighted, and it will exit on the
first exception it sees, no matter what.
I've tried everything, so I'm pretty sure that there's no clean solution in
2.7/3.3.
Cheers,
--
Juancarlo *Añez*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130512/a54a2009/attachment.html>
More information about the Python-ideas
mailing list