<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 12, 2013 at 3:48 AM, Devin Jeanpierre <span dir="ltr"><<a href="mailto:jeanpierreda@gmail.com" target="_blank">jeanpierreda@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>the code would be closure(block)()).<br>
<br>
Consider:<br>
<br>
>>> def closure(f):<br>
... f(); f(); f()<br>
...<br>
>>> @closure<br>
... def block():<br>
... print "Hi"<br>
...<br>
Hi<br>
Hi<br>
Hi</div></blockquote></div><br>Mmm. Interesting, but unpythonic.</div><div class="gmail_extra"><br></div><div class="gmail_extra">A decorator that executes the target right away?</div><div class="gmail_extra"><br></div><div class="gmail_extra" style>
I also tried:</div><div class="gmail_extra" style><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra" style><br></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div class="gmail_extra" style>with closure:<br> while True:<br> block</div></blockquote></div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>But the context-manager design is shortsighted, and it will exit on the first exception it sees, no matter what.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>I've tried everything, so I'm pretty sure that there's no clean solution in 2.7/3.3.</div><div class="gmail_extra"><br clear="all">
<div>Cheers,</div><div><br></div>-- <br><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b>
</div></div>