Quantcast
Viewing all articles
Browse latest Browse all 6129

Type annotations in pypy give an error but work in python3

Please compare the following two programs:

#!/usr/bin/env pypyi: float = 5.0

and this:

#!/usr/bin/env python3i: float = 5.0

The first one fails:

  File "./pypy_test.py", line 3    i: float = 5.0     ^SyntaxError: invalid syntax

The second one just runs. I thought pypy and Python were fully compatible. What could be going on?

The installation of pypy on my Ubuntu is just a few minutes old. I am running Python 3.10.12.

2023_11_25 14:57:08 maot@hunsn:~  $ pypy --versionPython 2.7.18 (7.3.9+dfsg-1, Apr 01 2022, 21:40:34)[PyPy 7.3.9 with GCC 11.2.0]2023_11_25 14:57:11 maot@hunsn:~  $ 

Viewing all articles
Browse latest Browse all 6129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>