[Python-ideas] Keyword to disambiguate python version

Tony Lownds tony at pagedna.com
Thu Aug 26 21:56:58 CEST 2010

On Aug 26, 2010, at 12:25 PM, Jonny wrote:

> I would propose that an idiomatic way is created, for instance a
> pragma or statement, which allows one to disambiguate the used python
> version in a manner that is both obvious for the human reader, and as
> well allows python to reject the script, should the wrong version of
> the interpreter be present. I think this is a quite common
> problem[1][2], which could be solved in a fairly easy and pragmatic
> way.

+1. I've found 3rd party libs where I only find out what version its compatible with
by tripping over the wrong module. IMO it would be great for a pragma like Jonny 
mentions to be well supported.

Here is a different take on mechanism and semantics.

First, I'd like to be able to use:


This allows a simple rough cut is a packaging issue, but IIRC the standard 
Makefile does not create python3. So the specific proposal is for the 
Makefile start doing that.  This thread might be worth reading re: this issue.

Second, for the pragma, how about something like:
__python__ = '2.4'

When a new Python version sees that in the main script, a warning 
should be issued if __python__ is assigned a value that is lower than 
the current version or doesn't match the version format. In addition, if a 
module is imported with a higher version of __python__ than either
the importing module or the main script, a warning should be issued.

When a lint program sees that, any features not present in the version 
of python assigned to __python__ should be an error. In addition, lint 
programs should check the use of modules using the semantics that Python


More information about the Python-ideas mailing list