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

Steven D'Aprano steve at pearwood.info
Sun Aug 17 11:45:36 CEST 2014


On Sun, Aug 17, 2014 at 09:33:13PM +1200, Greg Ewing 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?

mypy has Union[Iterable, Hashable], but that would mean anything 
iterable, or anything hashable, but not necessarily both at the same 
time. I don't see anything that says it must support both, but I've 
only gone through the tutorial:

http://mypy-lang.org/tutorial.html




-- 
Steven


More information about the Python-ideas mailing list