[Python-ideas] Optional static typing -- the crossroads

Łukasz Langa lukasz at langa.pl
Sun Aug 17 11:44:32 CEST 2014


On Aug 17, 2014, at 2:33 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> Stefan Behnel wrote:
>> However, it does not support protocols, so it still needs
>> something that allows us to say Iterable(int) in some way.
> 
> Just had a thought -- does mypy provide a way to express
> a type that supports more than one protocol? E.g. can you
> say that something must be both Iterable and Hashable?

That would be union types. Current syntax:
Union[Iterable[int], Hashable]

Proposed more concise syntax:
Iterable[int] | Hashable

-- 
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/20140817/105e9476/attachment.html>


More information about the Python-ideas mailing list