<div dir="ltr">Let's discuss this idea of "exactly" further in the tracker, where I just created an issue that touches on the same idea: <a href="https://github.com/ambv/typehinting/issues/52">https://github.com/ambv/typehinting/issues/52</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 20, 2015 at 11:31 PM, Stefan Behnel <span dir="ltr"><<a href="mailto:stefan_ml@behnel.de" target="_blank">stefan_ml@behnel.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Guido van Rossum schrieb am 19.01.2015 um 04:40:<br>
<span class="">> On Sun, Jan 18, 2015 at 12:36 PM, Stefan Behnel wrote:<br>
>> would be nice to at least be able to explicitly express somehow that<br>
>> subtypes should be disallowed.<br>
><br>
> Can you come up with a specific proposal? Maybe we're not as far apart as<br>
> we think. :-)<br>
<br>
</span>Normally, "x: List[int]" would mean that x is either a list or a subtype of<br>
list, where each item is an int or a subtype. To disallow subtypes, you<br>
could have something like "exactly(List)[int]" or "List[exactly(int)]" or<br>
"exactly(List[int])", which would then make it clear that the exact type<br>
matters, only for the List in the first case, only for the item type in the<br>
second, and (this is not necessarily required) for all types inside of the<br>
"exactly()" call in the last case. The return value of "exactly()" could be<br>
some kind of type wrapper object which marks the wrapped type construct as<br>
allowing "no subtypes".<br>
<br>
This would keep the normal case of allowing subtypes everywhere normal and<br>
simple, but would allow restricting the type to disallow subtypes in the<br>
cases where it seems appropriate.<br>
<div class="HOEnZb"><div class="h5"><br>
Stefan<br>
<br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>
</div>