<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Dec 22, 2014 at 3:54 AM, Petr Viktorin <span dir="ltr"><<a href="mailto:encukou@gmail.com" target="_blank">encukou@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Dec 22, 2014 at 8:02 AM, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
[...]<br>
<span class="">> limits -- e.g. repr() of Any is still a string, and Any==Any is still a<br>
> bool.<br>
<br>
</span>Why is Any==Any a bool?<br>
Comparison operators can return anything, and libraries like Numpy or<br>
SQLAlchemy take advantage of this (comparing Numpy arrays results in<br>
an array of bools, and comparing a SQLAlchemy Column to something<br>
results in a comparison expression, e.g. `query.filter(<a href="http://table.id" target="_blank">table.id</a> ==<br>
2)`). Would type checkers be expected to reject these uses?<br></blockquote><div><br></div><div>Never mind, I forgot about that. :-) <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
>From Pragmatics section in the article:<br>
> If a default of None is specified, the type is implicitly optional, e.g.<br>
>     def get(key: KT, default: VT = None) -> VT: ...<br>
<br>
Why is this limited to None? Can this be extended to "if there's a<br>
default argument, then that exact object is also allowed"? That would<br>
allow things like:<br>
<br>
    _MISSING = object()<br>
    def getattr(key: str, default: VT=_MISSING) -> VT: ...<br>
</blockquote></div><br></div><div class="gmail_extra">Well, that would require the type checker to be smarter. I don't want to go down the slippery path of defining compile-time expressions. Allowing None is easy (it's a keyword), useful and covers the common cases.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>
</div></div>