<div dir="ltr">Thank you for the clarification! I should have looked through the PEPs first.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 25, 2018 at 10:14 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">PEP 526 has this in the "Rejected/Postponed Proposals" section:<br><br>- **Allow annotations in** ``with`` **and** ``for`` **statement:**<br>  This was rejected because in ``for`` it would make it hard to spot the actual<br>  iterable, and in ``with`` it would confuse the CPython's LL(1) parser.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Jan 25, 2018 at 3:17 PM, Jelle Zijlstra <span dir="ltr"><<a href="mailto:jelle.zijlstra@gmail.com" target="_blank">jelle.zijlstra@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-5085297703640048796h5">2018-01-25 15:00 GMT-08:00 Joe Jevnik via Python-Dev <span dir="ltr"><<a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Currently there are many ways to introduce variables in Python; however, only a few allow annotations. I was working on a toy language and chose to base my syntax on Python's when I noticed that I could not annotate a loop iteration variable. For example:<br><br></div>for x: int in range(5):<br>    ...<br><br></div>This led me to search for other places where new variables are introduced and I noticed that the `as` target of a context manager cannot have an annotation. In the case of a context manager, it would probably need parenthesis to avoid ambiguity with a single-line with statement, for example:<br><br></div>with ctx as (variable: annotation): body<br></div><div><br></div><div>Finally, you cannot annotate individual members of a destructuring assignment like:</div><div><br></div><div>a: int, b: int, c: int = 1, 2, 3</div><div><br></div>Looking at the grammar, these appear to be `expr` or `exprlist` targets. One change may be to allow arbitrary expressions to have an annotation . This would be a small change to the grammar but would potentially have a large effect on the language or static analysis tools.<br><br></div>I am posting on the mailing list to see if this is a real problem, and if so, is it worth investing any time to address it. I would be happy to attempt to fix this, but I don't want to start if people don't want the change. Also, I apologize if this should have gone to python-idea; this feels somewhere between a bug report and implementation question more than a new feature so I wasn't sure which list would be more appropriate.<br></div></div></blockquote></div></div><div>I have written a fair amount of code with variable annotations, and I don't remember ever wanting to add annotations in any of the three contexts you mention. In practice, variable annotations are usually needed for class/instance variables and for variables whose type the type checker can't infer. The types of loop iteration variables and context manager assignment targets can almost always be inferred trivially.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div></div>
<br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/jelle.zijlstra%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/jelle.zij<wbr>lstra%40gmail.com</a><br>
<br></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br></div></div>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/guido%<wbr>40python.org</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="m_-5085297703640048796gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</font></span></div>
</blockquote></div><br></div>