Issue 491331: request sys.required_version - Python tracker (original) (raw)

Issue491331

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 sys.required_version(2,2,0) Thank you!
msg61075 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-12-10 22:25
Logged In: YES user_id=31435 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: try: . 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 :-).
History
Date User Action Args
2022-04-10 16:04:45 admin set github: 35713
2008-01-21 22:15:48 draghuram set status: open -> closednosy: + draghuramresolution: rejectedmessages: +
2001-12-10 22:12:21 dortmann create