codehaus


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to write differently to remove this type hint in Python 2.7?


On 10/21/20 3:24 PM, Shaozhong SHI wrote:
> Is there another way to do this?
> 
> def greet(name: str) -> str:
>     return "Hello, " + name
> greet
> 
> File "<ipython-input-28-bee2cddf1f0d>", line 1 def greet(name: str) -> str:
> ^ SyntaxError: invalid syntax
> 

The hinting pep PEP (484) has an alternate syntax that doesn't break 2.7.