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

Steven D'Aprano steve at pearwood.info
Thu Aug 14 20:55:55 CEST 2014


On Thu, Aug 14, 2014 at 12:28:26PM +0200, Manuel Cerón wrote:

> One interesting feature of TypeScript is that it allows you to annotate
> existing code without modifying it, by using external definition files. In
> the JavaScript world, many people have contributed TypeScript annotation
> files for popular JS libraries (http://definitelytyped.org/).
> 
> I think this is possible in Python as well doing something like this:
> 
> @annotate('math.ciel')
> def ciel(x: float) -> int:
>     pass

I'm afraid I don't understand what the annotate decorator is doing here. 
Can you explain please?




-- 
Steven


More information about the Python-ideas mailing list