<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-05-23 17:54 GMT+03:00 Mike Miller <span dir="ltr"><<a href="mailto:python-ideas@mgmiller.net" target="_blank">python-ideas@mgmiller.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
On 2018-05-22 14:32, Kirill Balunov wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
    # in global scope everything works ok since locals is globals<br>
     >>> while len( this( val = dummy() ) ) >= 0:<br>
    ...     print(val)<br>
    [0, 1]<br>
    [0, 1, 2]<br>
    [0, 1, 2, 3]<br>
</blockquote>
<br></span>
Interesting!  Although the example with a len() and mutable default arguments obscured the utility, I thought.  Also, why limit it to one assignment?<br>
<br></blockquote><div><br></div><div>I just want some dummy example which can not be trivially handled with `<font face="monospace, monospace">for name in iter(func, value)</font>`. But the latter is also only partly true. You can make something like: </div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="monospace, monospace">class P:</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="monospace, monospace">    __slots__ = ('func')</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="monospace, monospace">    def __init__(self, func):</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="monospace, monospace">        self.func = func    </font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="monospace, monospace">    def __eq__(self, other):</font></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><div><font face="monospace, monospace">        return not self.func(other)</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><div>for val in iter(dummy, P(lambda x: len(x) < 5)):</div><div>    print(val)</div><div><br></div><div><div>[0, 1]</div><div>[0, 1, 2]</div><div>[0, 1, 2, 3]</div></div><div><br></div></font></div></div></div></blockquote><font face="arial, helvetica, sans-serif">The only restriction is that you can not pass arguments to a `</font><font face="monospace, monospace">func</font><font face="arial, helvetica, sans-serif">`, but this, <span style="color:rgb(34,34,34);font-family:arial,helvetica,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">to some extent, </span>can also be handled with lambda. I limit it to _one assignment_ firstly to make it simple, and secondly to get rid of some edge cases.</font><br><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Liked Terry's suggestions for name.  The name that jumped into my brain as I read was a reuse of the locals() or globals() callable with key words, that would change their behavior to what you suggest.</blockquote></div><br></div><div class="gmail_extra">I like `<font face="monospace, monospace">this</font>` because it is easy to follow in my opinion: "

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">While this name assigned to an expression is  greater than zero do...</span>

" But of course I'm open to any other spelling. I'm just wondering, if someone like this form as an alternative for assignment expression (`<font face="monospace, monospace">:=</font>`).</div><div class="gmail_extra"><br></div><div class="gmail_extra">With kind regards,</div><div class="gmail_extra">-gdg</div><div class="gmail_extra"><br></div></div>