PEP suggestion: Uniform way to indicate Python language version

Steve D'Aprano steve+python at pearwood.info
Fri Sep 9 21:33:11 EDT 2016


On Tue, 23 Aug 2016 12:29 am, Random832 wrote:

> Receiving a SyntaxError or whatever other exception, which provides no
> suggestion about how to actually fix the issue (install a later version
> of python / run with "python3" instead of "python"), is a bad user
> experience.

Er wot?

If I run the following code in Python 3.4:

    x:int = spam.method(?) - 1

how is the 3.4 interpreter supposed to know when the x:int and the (?)
syntax were introduced? I can tell you when x:int is introduced (Python
3.6) but I have no idea when (?) will be introduced, or what it will mean.


> It will continue to be a bad user experience when people are 
> using features that only work on python 5.0 and later and other people
> are trying to run their scripts under python 4.0, 

Suppose that version 4.5 introduces |: syntax and version 4.8 removes it
again because it was a terrible idea. And 4.9 introduces unless
expressions. I write this:

    x = spam |: eggs unless ValueError then cheese

What syntax error should Python 4.0 give?




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list