<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Aug 13, 2014, at 18:56, Ćukasz Langa <<a href="mailto:lukasz@langa.pl">lukasz@langa.pl</a>> wrote:</div><div><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">On Aug 13, 2014, at 6:39 PM, Andrew Barnert <<a href="mailto:abarnert@yahoo.com.dmarc.invalid">abarnert@yahoo.com.dmarc.invalid</a>> wrote:<br><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: 'Lucida Grande';  font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div></div><div><blockquote type="cite">On Wednesday, August 13, 2014 12:45 PM, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br><br><blockquote type="cite">  def word_count(input: List[str]) -> Dict[str, int]:<br>      result = {}  #type: Dict[str, int]<br>      for line in input:<br>          for word in line.split():<br>              result[word] = result.get(word, 0) + 1<br>      return result<br></blockquote><br>I just realized why this bothers me.<br><br>This function really, really ought to be taking an Iterable[String]</blockquote><div><br></div><div>You do realize String also happens to be an Iterable[String], right?</div></div></div></blockquote><div><br></div><div>Of course, but that's not a new problem, so I didn't want to bring it up. The fact that the static type checker couldn't reject word_count(f.read()) is annoying, but that's not the fault of the static type checking proposal.</div><br><blockquote type="cite"><div> One of my big dreams about Python is that one day we'll drop support for strings being iterable. Nothing of value would be lost and that would enable us to use isinstance(x, Iterable) and more importantly isinstance(x, Sequence). Funny that this surfaces now, too.</div></blockquote><br><div>IIRC, str doesn't implement Container, and therefore doesn't implement Sequence, because its __contains__ method is substring match instead of containment. So if you really want to treat sequences of strings separately from strings, you can. If only that really _were_ more important than Iterable, but I think the opposite is true.</div><div><br></div><div>But anyway, this is probably off topic, so I'll stop here.</div></body></html>