[RELEASED] Python 3.5.0b2 is now available

Steven D'Aprano steve at pearwood.info
Sat Jun 6 05:56:57 EDT 2015


On Sat, 6 Jun 2015 07:24 pm, Joonas Liik wrote:

> Perhaps its just me, but it seems to me that this release is mighty picky
> about annotations.
> 
> More specifically everything is fine in the interactive interpreter but
> the same code won't fly when run as a file.
> 
> example:
> def some_function(my_arg:"my random annotation")->"my random return type
> annotation":
>     pass
> 
> ..will fail with a syntax error when run from a file.


Three likely possibilities, and one unlikely one:

(1) When you are running from a file, you are accidentally using the wrong
Python interpreter and trying to use Python 2 by mistake.

(2) When you are running from a file, you have invisible control characters
in the file, or the encoding is not set correctly, and are getting a
SyntaxError due to the control characters, nothing to do with annotations.

(3) There is some other syntax error in your file.

And the unlikely one:

(4) There's a bug in the interpreter.


If you would care to inspect the syntax error, you will see that when Python
finds a syntax error, it points at the offending token, or just after it,
using a ^ caret. That may give you some hint as to what the issue is.




-- 
Steven




More information about the Python-list mailing list