Python Sanity Proposal: Type Hinting Solution

Tim Chase python.list at
Sat Jan 24 13:47:03 CET 2015

On 2015-01-24 17:21, Steven D'Aprano wrote:
> # Cobra
> def sqroot(i as int) as float
> # Python
> def sqroot(i:int)->float:
> Cobra's use of "as" clashes with Python. In Python, "as" is used for
> name-binding:
> import module as name
> with open('file') as f
> except Exception as e
> but apart from that minor difference, they're virtually identical.

Though given that

 def sqrt(i as int) as float:

is invalid Python syntax (both in the parameter list and as the
return value of the function), the meaning of "as" could be overloaded
in both senses to allow for the Cobra-like syntax.


More information about the Python-list mailing list