This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: request sys.required_version
Type: enhancement Stage:
Components: Library (Lib) Versions:
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: dortmann, draghuram, tim.peters
Priority: normal Keywords:

Created on 2001-12-10 22:12 by dortmann, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (3)
msg61074 - (view) Author: Daniel Ortmann (dortmann) Date: 2001-12-10 22:12
In Perl, "require 5.04" conveniently specifies the
minimum level of Perl required to run the script.

I expected to find something similar in the Python sys
module, but this is as close as I can come:

import sys

assert (2,2) <= sys.version_info[:2], "python version
is too old!"

It seems to me that I should be able to say something like:

import sys

Thank you!
msg61075 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-12-10 22:25
Logged In: YES 

Because Python has a full-blown exception system, it's 
generally better to test for the feature you need than to 
compare mysterious little integers.  For example, suppose 
you need list comprehensions.  You have no idea which 
version of Python first introduced them, and once you think 
you've got it figured out, readers of your code are going 
to have no idea that you *meant* "list comprehensions" when 
you compare sys.version_info against (2, 0).  So clearer 
all around is:

.   eval("[i for i in range(2)]")
except SyntaxError:
.   raise ImportError, "I require list comprehensions"
msg61459 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2008-01-21 22:15
should have been closed long time back :-).
Date User Action Args
2022-04-10 16:04:45adminsetgithub: 35713
2008-01-21 22:15:48draghuramsetstatus: open -> closed
nosy: + draghuram
resolution: rejected
messages: + msg61459
2001-12-10 22:12:21dortmanncreate