<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> print(child_pid)  # child_pid is undefined<br>
<br>
</span>Why on earth would it be undefined?<br></blockquote><div><br></div><div>Indeed, users would expect the new uses of "as" to behave as the previous ones. The problem is that "with"  and "except" do things differently:</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><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">In [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(46,231,33)"><b>1</b></span><span style="font-variant-ligatures:no-common-ligatures">]: <b>import</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(60,159,242)"><b>os</b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8);min-height:14px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,163,39)">In [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(46,231,33)"><b>2</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,163,39)">]: <b>with</b></span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,163,39)">open</span><span style="font-variant-ligatures:no-common-ligatures">(os.path.expanduser(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">'~/tmp/xx'</span><span style="font-variant-ligatures:no-common-ligatures">)) </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,163,39)"><b>as</b></span><span style="font-variant-ligatures:no-common-ligatures"> f:</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">   ...: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">    </span><span style="font-variant-ligatures:no-common-ligatures"><b>pass</b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">   ...: </span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8);min-height:14px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">In [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(46,231,33)"><b>3</b></span><span style="font-variant-ligatures:no-common-ligatures">]: print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">(f)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures"><_io.TextIOWrapper name='/Users/apalala/tmp/xx' mode='r' encoding='UTF-8'></span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8);min-height:14px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">In [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(46,231,33)"><b>4</b></span><span style="font-variant-ligatures:no-common-ligatures">]: <b>try</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">:</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">   ...: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">    </span><span style="font-variant-ligatures:no-common-ligatures">print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(205,121,35)">'ok'</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">   ...: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">    </span><span style="font-variant-ligatures:no-common-ligatures"><b>raise</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(242,119,117)"><b>Exception</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">()</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">   ...: <b>except</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(242,119,117)"><b>Exception</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)"> </span><span style="font-variant-ligatures:no-common-ligatures"><b>as</b></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)"> e:</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">   ...: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">    </span><span style="font-variant-ligatures:no-common-ligatures"><b>pass</b></span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">   ...: </span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">In [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(46,231,33)"><b>5</b></span><span style="font-variant-ligatures:no-common-ligatures">]: print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">(e)</span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(195,55,32);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">---------------------------------------------------------------------------</span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">NameError</span><span style="font-variant-ligatures:no-common-ligatures">                                 Traceback (most recent call last)</span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,188,38);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures"><ipython-input-5-bb2ea196f768></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)"> in </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(52,187,200)"><module></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(82,48,225)">()</span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,188,38);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures">----> 1</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">print</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(82,48,225)">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(244,244,244)">e</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(82,48,225)">)</span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8);min-height:14px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(52,163,39);background-color:rgba(0,0,0,0.8)">





</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(244,244,244);background-color:rgba(0,0,0,0.8)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">NameError</span><span style="font-variant-ligatures:no-common-ligatures">: name 'e' is not defined</span></p></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Anyway, if you want to propose an alternative to PEP 572, you ought to <br>
write your own competing PEP.<span class="gmail-HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>I don't take that as a challenge. It would be good to have different, maybe somewhat competing PEPs. It's been done before.</div><div><br></div><div><br></div></div>-- <br><div class="gmail_signature"><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b></div>
</div></div>