<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 13, 2013 at 2:40 PM, Bruce Leban <span dir="ltr"><<a href="mailto:bruce@leapyear.org" target="_blank">bruce@leapyear.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>This is a much more common scenario than wanting anonymous blocks. I'm not proposing to change this. I'm just pointing out that if you're complaining about not being able to assign a value inside a statement, there are more common cases to look at.</div>



<div></div></blockquote></div><br>I'm not complaining. I'm just pointing out that there may be more readable ways to express things in Python than out-of-order.</div><div class="gmail_extra"><br></div><div class="gmail_extra">

I know that making def and class be expressions would cause enormous problems. Because context managers are limited to their intended purpose, I proposed new syntax that would provide for anonymous blocks in certain places.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Instead of having to do:</div><div class="gmail_extra" style><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra" style>
<br>
def synthetic1():<br>     self.match('a')  <br>     def synthetic2():<br>        self.match('b')<br>    self.closure(synthetic1)<br>self.closure(synthetic2)</div><div class="gmail_extra" style><br></div></blockquote>

Which is as close to cryptic as can bee, it could be:</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra" style>

within self.closure():</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra" style>    self.match('a')<br>    within self.closure():</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">

<div class="gmail_extra" style>         self.match('b')</div></blockquote><div class="gmail_extra" style><br></div><div class="gmail_extra" style>Which is, at least, in the right order. Adding the new keyword would allow reusing the parsing for def:</div>

<div class="gmail_extra" style><br></div><div class="gmail_extra" style><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra">within self.closure():<br>    def():</div></blockquote>
<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div class="gmail_extra">        self.match('a')<br>        within self.closure():<br>             def():</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra">

                  self.match('b')</div><div><br></div></blockquote></div><div class="gmail_extra" style>So anonymous blocks can also take parameters, without the need to make def an assignable expression.</div><div class="gmail_extra" style>

<br></div>Cheers,<br clear="all"><div style><br></div>-- <br><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b>
</div></div>