<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>That should probably be its own thread<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> Python-ideas [mailto:python-ideas-bounces+tritium-list=sdamon.com@python.org] <b>On Behalf Of </b>Robert Vanden Eynde<br><b>Sent:</b> Wednesday, February 28, 2018 4:48 PM<br><b>Cc:</b> python-ideas <python-ideas@python.org><br><b>Subject:</b> Re: [Python-ideas] PEP 572: Statement-Local Name Bindings<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>We are currently like a dozen of people talking about multiple sections of a single subject.<br><br>Isn't it easier to talk on a forum?<br><b>Am I the only one</b> who thinks mailing list isn't easy when lots of people talking about multiple subjects?<br><br>Of course we would put the link in the mailing list so that everyone can join.<br><br>A forum (or just few "issues" thread on github) is where we could have different thread in parallel, in my messages I end up with like <b>10 comments not all related</b>, in a forum we could talk about everything and it would still be organized by subjects.<br><br>Also, it's more interactive than email on a global list, people can talk to each other in parallel, if I want to answer about a mail that was 10 mail ago, it gets quickly messy.<o:p></o:p></p></div><p class=MsoNormal>We could all discuss on a gist or some "Issues" thread on GitHub.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>2018-02-28 22:38 GMT+01:00 Robert Vanden Eynde <<a href="mailto:robertve92@gmail.com" target="_blank">robertve92@gmail.com</a>>:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Le 28 févr. 2018 11:43, "Chris Angelico" <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a>> a écrit :<br><br>> It's still right-to-left, which is as bad as middle-outward once you<br>> combine it with normal left-to-right evaluation. Python has very<br>> little of this [..]<br><br>I agree [....]<br><br>>> 2) talking about the implementation of thektulu in the "where =" part.<br><br>> ?<br><br>In the Alternate Syntax, I was talking about adding a link to the <a href="https://github.com/thektulu/cpython/commits/where-expr" target="_blank">thektulu (branch where-expr)</a><br>implementation as a basis of proof of concept (as you did with the other syntax).<br><br>>> 3) "C problem that an equals sign in an expression can now create a name inding, rather than performing a comparison."<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>As you agreed, with the "ch with ch = getch()" syntax we won't accidentally switch a "==" for a "=".<o:p></o:p></p></div><p class=MsoNormal>I agree this syntax :<o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>```<br>while (ch with ch = getch()):<br>    ...<br>```<o:p></o:p></p></div><div><p class=MsoNormal>doesn't read very well, but in the same way as in C or Java while(ch = getch()){} or worse ((ch = getch()) != null) syntax.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Your syntax "while (getch() as ch):" may have a less words, but is still not clearer.<o:p></o:p></p></div><div><p class=MsoNormal>As we spoke on Github, having this syntax in a while is only useful if the variable does leak.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>>> 5) Any expression vs "post for" only<br><br>> I don't know what the benefit is here, but sure. As long as the<br>> grammar is unambiguous, I don't see any particular reason to reject<br>> this.<o:p></o:p></p></div><div><p class=MsoNormal>I would like to see a discussion of pros and cons, some might think like me or disagree, that's a strong langage question.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>> 6) with your syntax, how does the simple case work (y+2 with y = x+1) ?<br><br>What simple case? The case where you only use the variable once? I'd<br>write it like this:<br><br>(x + 1) + 2<br><br>>> The issue is not only about reusing variable.<br><br>> If you aren't using the variable multiple times, there's no point<br>> giving it a name. Unless I'm missing something here?<o:p></o:p></p></div><div><p class=MsoNormal>Yes, variables are not there "just because we reuse them", but also to include temporary variables to better understand the code.<o:p></o:p></p></div><div><p class=MsoNormal>Same for functions, you could inline functions when used only once, but you introduce them for clarity no ?<o:p></o:p></p></div><div><p class=MsoNormal><br>```<o:p></o:p></p></div><div><p class=MsoNormal>a = v ** 2 / R # the acceleration in a circular motion<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>f = m * a # law of Newton<br>```<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>could be written as <o:p></o:p></p><div><p class=MsoNormal>```<o:p></o:p></p></div><p class=MsoNormal>f = m * (v ** 2 / R) # compute the force, trivial<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>```<o:p></o:p></p></div><div><p class=MsoNormal>But having temporary variables help a lot to understand the code, otherwise why would we create temporary variables ?<o:p></o:p></p></div><div><p class=MsoNormal>I can give you an example where you do a process and each time the variable is used only one.<o:p></o:p></p></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>>> 8)<br>>>  (lambda y: [y, y])(x+1)<br>>> Vs<br>>> (lambda y: [y, y])(y=x+1)<br><br>Ewww. Remind me what the benefit is of writing the variable name that<br>many times? "Explicit" doesn't mean "utterly verbose".<o:p></o:p></p></div><div><p class=MsoNormal>Yep it's verbose, lambdas are verbose, that's why we created this PEP isn't it :)<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>> 10) Chaining, in the case of the "with =", in thektulu, parenthesis were<br>> mandatory:<br>><br>> print((z+3 with z = y+2) with y = x+2)<br>><br>> What happens when the parenthesis are dropped ?<br>><br>> print(z+3 with y = x+2 with z = y+2)<br>><br>> Vs<br>><br>> print(z+3 with y = x+2 with z = y+2)<br>><br>> I prefer the first one be cause it's in the same order as the "post for"<br>><br>> [z + 3 for y in [ x+2 ] for z in [ y+2 ]]<br><br>> With my proposal, the parens are simply mandatory. Extending this to<br>> make them optional can come later.<o:p></o:p></p></div><div><p class=MsoNormal>Indeed, but that's still questions that can be asked.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>>> 11) Scoping, in the case of the "with =" syntax, I think the parenthesis<br>>> introduce a scope :<br>>><br>>> print(y + (y+1 where y = 2))<br>>><br>>> Would raise a SyntaxError, it's probably better for the variable beeing<br>>> local and not in the current function (that would be a mess).<br>>><br>>> Remember that in list comp, the variable is not leaked :<br>>><br>>> x = 5<br>>> stuff = [y+2 for y in [x+1]<br>>> print(y) # SyntaxError<br><br>> Scoping is a fundamental part of both my proposal and the others I've<br>> seen here. (BTW, that would be a NameError, not a SyntaxError; it's<br>> perfectly legal to ask for the name 'y', it just hasn't been given any<br>> value.) By my definition, the variable is locked to the statement that<br>> created it, even if that's a compound statement. By the definition of<br>> a "(expr given var = expr)" proposal, it would be locked to that<br>> single expression.<o:p></o:p></p></div><div><p class=MsoNormal>Confer the discussion on scoping on github (<a href="https://github.com/python/peps/commit/2b4ca20963a24cf5faac054226857ea9705471e5" target="_blank">https://github.com/python/peps/commit/2b4ca20963a24cf5faac054226857ea9705471e5</a>) :<o:p></o:p></p><div><p>"""<br>In the current implementation it looks like it is like a regular assignment (function local then).<o:p></o:p></p><p>Therefore in the expression usage, the usefulness would be debatable (just assign before).<o:p></o:p></p><p>But in a list comprehension <em><span style='font-family:"Calibri",sans-serif'>after the for</span></em> (as I mentioned in my mail), aka. when used as a replacement for <code><span style='font-size:10.0pt'>for y in [ x + 1 ]</span></code> this would make sense.<o:p></o:p></p><p>But I think that it would be much better to have a local scope, in the parenthesis. So that <code><span style='font-size:10.0pt'>print(y+2 where y = x + 1)</span></code> wouldn't leak y. And when there are no parenthesis like in <code><span style='font-size:10.0pt'>a = y+2 where y = x+1</span></code>, it would imply one, giving the same effect as <code><span style='font-size:10.0pt'>a = (y+2 where y = x+1)</span></code>. Moreover, it would naturally shadow variables in the outermost scope.<o:p></o:p></p><p>This would imply <code><span style='font-size:10.0pt'>while data where data = sock.read():</span></code> does not leak <code><span style='font-size:10.0pt'>data</span></code> but as a comparison with C and Java, the syntax while((data = sock.read()) != null) is really really ugly and confusing.<o:p></o:p></p></div><p class=MsoNormal>"""<o:p></o:p></p></div></div></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></div></body></html>