On Thu, Oct 22, 2020 at 8:26 AM Shaozhong SHI <shishaozh...@gmail.com> 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
If you need to support Python 2, don't use annotations. It's that simple. :) Bear in mind that Python 2 is now extremely old, and is no longer supported. A much better option is to use a newer interpreter. ChrisA -- https://mail.python.org/mailman/listinfo/python-list