#!/usr/bin/env python > 2.4?

rh0dium steven.klass at gmail.com
Tue Mar 20 21:23:44 CET 2007

On Mar 20, 12:30 pm, Stargaming <stargam... at gmail.com> wrote:
> from sys import version_info
> if version_info[0] < 2 or version_info[1] < 4:
>      raise RuntimeError("You need at least python2.4 to run this script")

This is great!!

> IMO you shouldn't struggle with it too hard. If the user's python
> version is not appropriate, don't hack its interpreter mechanism to do
> the work you need. Anyways, you should not check for specific python
> versions but for modules/APIs/builtins whatever and *then* you may raise
> an exception pointing the user to the fact that is python version does
> not fit your needs.

I agree but where do you raise the exception?  Quite frankly it's
silly to kill the whole app when a bunch of debug lines won't print
and shouldn't except by the developer..
In other words is what you propose the right way to solve this for
modules which were'nt included in older python releases?  Or should I
be doing something different and if so what should I do?  I like the
solution you give - it will work for everything I do - but is it smart
to retrofit this into all of my old code?  What is the clean way to
solve this?

Just want to do this the right way.

More information about the Python-list mailing list