PEP 260: simplify xrange()
Chris Lawrence
quango at watervalley.net
Fri Jun 29 04:42:44 EDT 2001
In article <3B3AA617.8A9B56B7 at seebelow.org>, "Grant Griffin"
<not.this at seebelow.org> wrote:
> BTW, can PyChecker do Python-version enforcement? Specifically, I think
> it would be great if we had a gizmo at least to enforce 1.5.2 (besides
> 1.5.2 itself <wink>).
>
> Even cooler would be if Python had some sort of feature for this. (I'd
> write a PEP for that, but I fear that it might lead to a new version
> <wink>.) But I guess for reasons of efficiency something like this
> should be an "offline" tool anyway rather than pollute the innards of
> Python.
You can try this code at the beginning of your program:
import sys
try:
if sys.hexversion < 0x10502f0: # 1.5.2 final
print 'Get a new version of Python!'
except AttributeError:
print 'Get a new version of Python!'
Dunno when sys.hexversion showed up, hence the try clause.
With more recent versions, you could also play with sys.version_info.
Chris
More information about the Python-list
mailing list