<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2018-04-12 12:48 GMT+03:00 Jacco van Dorp <span dir="ltr"><<a href="mailto:j.van.dorp@deonet.nl" target="_blank">j.van.dorp@deonet.nl</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">Wouldn't these local name bindings make the current "as" clause of<br>
"with f(x) as y" completely obsolete ?<br>
<br>
It's probably good to know my background, and my background is that I<br>
know completely nothing of the implementation, im only junior software<br>
engineer, and python was my first programming experience, and still<br>
the one I have by far the most experience with.<br>
<br>
To me, the entire proposal sounds mostly like an expansion of the as<br>
syntax as we know it from "with". There will be no difference between:<br>
<br>
with open(filename) as f:<br>
    // code<br>
<br>
and<br>
<br>
with f  := open(filename):<br>
    // code<br>
<br>
or at least as far as I can see. (that is, if := will be allowed in<br>
the with statement, and it sounds like it will ?)<br>
<br></blockquote></div><br></div><div class="gmail_extra">Thank you Jacob! 
<span id="gmail-result_box" class="gmail-" lang="en"><span class="gmail-">I do not know if I understood correctly how you understand what is happening here</span></span>. But you are just demonstrating my fears about this proposal...<br><br><div style="margin-left:40px">
<span style="font-family:monospace,monospace">with f  := open(filename):

<br></span></div><br></div><div class="gmail_extra">This will be only valid if the returned object of 
<span style="font-family:monospace,monospace">(f := open(filename)) </span><span style="font-family:arial,helvetica,sans-serif">defines <span style="font-family:monospace,monospace">__enter__</span> and <span style="font-family:monospace,monospace">__exit__</span> methods (
<span id="gmail-result_box" class="gmail-short_text" lang="en"><span class="gmail-">Nevertheless, in this situation it is so</span></span>). But in other cases it will raise an error. Generally 
<span style="font-family:monospace,monospace">`with name  := expr` </span>is not equivalent to<span style="font-family:monospace,monospace">
`with expr as name:`. </span>In another places, for example,<span style="font-family:monospace,monospace"> `except` </span>clause<span style="font-family:monospace,monospace"> `f := something` </span>is valid only<span style="font-family:monospace,monospace"> </span>if the returned type is an object, which inherit from<span style="font-family:monospace,monospace"> BaseException. </span>So in this two situations, in my opinion, it will not be used too much<span style="font-family:monospace,monospace">. <br><br></span>Yours example under current proposal should look like  <span style="font-family:monospace,monospace">`with open( full_file_path := 
<span style="font-family:arial,helvetica,sans-serif"><span style="font-family:monospace,monospace">os.path.join(path, filename</span></span>) ) as f:`. </span><span style="font-family:monospace,monospace"><br><br></span></span></div><div class="gmail_extra"><span style="font-family:arial,helvetica,sans-serif">With kind regards,<br></span></div><div class="gmail_extra"><span style="font-family:arial,helvetica,sans-serif">-gdg<span style="font-family:monospace,monospace"><br></span>

</span>

</div><div class="gmail_extra"><span style="font-family:monospace,monospace"></span></div></div>