<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 9 May 2018 at 03:57, Tim Peters <span dir="ltr"><<a href="mailto:tim.peters@gmail.com" target="_blank">tim.peters@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">These all match my expectations.  Some glosses:<br>
<br>
[Guido]<br>
<span class="gmail-">> We should probably define what happens when you write [p := p for p in<br>
> range(10)]. I propose that this overwrites the loop control variable rather<br>
> than creating a second p in the containing scope -- either way it's probably<br>
> a typo anyway.<br>
<br>
</span>A compile-time error would be fine by me too.  Creating two meanings<br>
for `p` is nuts - pick one in case of conflict.  I suggested before<br>
that the first person with a real use case for this silliness should<br>
get the meaning their use case needs, but nobody bit, so "it's local<br>
then" is fine.<br></blockquote><div><br></div><div>I'd suggest that the handling of conflicting global and nonlocal declarations provides a good precedent here: <br></div><div><br>>>> def f():<br>...     global x<br>...     nonlocal x<br>...     x = 1<br>... <br>  File "<stdin>", line 2<br>SyntaxError: name 'x' is nonlocal and global<br><br></div><div>Since using a name as a binding target *and* as the iteration variable would effectively be declaring it as both local and nonlocal, or as local and global.</div><br><div>Cheers,<br></div><div>Nick.<br></div></div><br>-- <br><div class="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</div>
</div></div>