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

2020-10-21 Thread Mats Wichmann
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 "", line 1 def greet(name: str) -> str: > ^ SyntaxError: invalid syntax > The hinting pep PEP (484) has an alternate syntax that doesn't b

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

2020-10-21 Thread Chris Angelico
On Thu, Oct 22, 2020 at 8:26 AM Shaozhong SHI wrote: > > Is there another way to do this? > > def greet(name: str) -> str: > return "Hello, " + name > greet > > File "", line 1 def greet(name: str) -> str: > ^ SyntaxError: invalid syntax If you need to support Python 2, don't use annotations.

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

2020-10-21 Thread Shaozhong SHI
Is there another way to do this? def greet(name: str) -> str: return "Hello, " + name greet File "", line 1 def greet(name: str) -> str: ^ SyntaxError: invalid syntax -- https://mail.python.org/mailman/listinfo/python-list

How to create a C Extension that uses CPython internals (outside limited API)?

2020-10-21 Thread Marco Sulla
I'm working on a C extension for frozendict. To make it working, I had to: 1. add by hand the whole path of dictobject.c (/home/marco/sources/cpython/Objects/dictobject.c) 2. add -DPy_BUILD_CORE 3. add the whole path of CPython includes (/home/marco/sources/cpython/Include and so on) This works o