PEP 260: simplify xrange()
Grant Griffin
not.this at seebelow.org
Sat Jun 30 22:49:39 EDT 2001
Chris Lawrence wrote:
>
> 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.
Thanks for the suggestion, Chris, but I guess I was thinking more of
"backwards compatibility" issues. This comes up currently for me
because I am writing a CGI app, and version 1.5.2 of Python still seems
to be installed on web servers (because, until recently, at least, it
appeared in most Linux distributions.)
For that reason, for example, it would be nice to be able to
automatically know that something developed using Python 2.1 was free of
string methods so it would run on 1.5.2. (Even better would be a
"backwards-version source-code translator"--that is, something besides
my tired brain and aching fingers <wink>.)
only-microsoft-succeeds-in-making-nearly-each-and-every-old-horse
-who-uses-its-software-"upgrade"-to-each-new-water-ly y'rs,
=g2
--
_____________________________________________________________________
Grant R. Griffin g2 at dspguru.com
Publisher of dspGuru http://www.dspguru.com
Iowegian International Corporation http://www.iowegian.com
More information about the Python-list
mailing list