Python Sanity Proposal: Type Hinting Solution

Tim Chase python.list at tim.thechases.com
Sat Jan 24 07:47:03 EST 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.
-tkc


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /