<p dir="ltr">Note that no other feature in typing is about the reference - everything is about the objects themselves. Final makes less sense as a general type. We can't enforce A[T]().foo() not to reassign a Final T.</p>
<p dir="ltr">Elazar </p>
<br><div class="gmail_quote"><div dir="ltr">בתאריך יום ג׳, 21 בנוב׳ 2017, 12:42, מאת Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">On 21 November 2017 at 10:47, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></span> wrote:<br></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">-1. I don't see how this would improve any programs I've written or<br>
seen. Tools like mypy or linters might benefit from a feature to track<br>
constants and ensure they don't get changed<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It is actually likely that something like this will appear in ``typing``:</div><div><br></div><div> from typing import Final, List<br></div><div><br></div><div> x: Final = 42</div><div> x = 1 # Fails type check</div><div><br></div><div> lst: Final[List[int]] = []</div><div> lst.append(5) # OK</div><div> lst = [1, 2, 3] # Fails type check<br></div><div><br></div><div>--</div><div>Ivan</div><div><br></div><div><br></div></div></div></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>