[Python-ideas] Proposal: Use mypy syntax for function annotations

Łukasz Langa lukasz at langa.pl
Thu Aug 14 03:56:54 CEST 2014


On Aug 13, 2014, at 6:39 PM, Andrew Barnert <abarnert at yahoo.com.dmarc.invalid> wrote:

> On Wednesday, August 13, 2014 12:45 PM, Guido van Rossum <guido at python.org> wrote:
> 
>>   def word_count(input: List[str]) -> Dict[str, int]:
>>       result = {}  #type: Dict[str, int]
>>       for line in input:
>>           for word in line.split():
>>               result[word] = result.get(word, 0) + 1
>>       return result
> 
> I just realized why this bothers me.
> 
> This function really, really ought to be taking an Iterable[String]

You do realize String also happens to be an Iterable[String], right? 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.

-- 
Best regards,
Łukasz Langa

WWW: http://lukasz.langa.pl/
Twitter: @llanga
IRC: ambv on #python-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140813/c71b6f91/attachment.html>


More information about the Python-ideas mailing list