Checking Python version in a program

Preston Landers prestonlanders at my-deja.com
Thu Mar 2 13:15:16 EST 2000


Well, normally I would agree that this is smarter, but in some cases it
seems that the modules will be availible in both versions, and even the
same classes / functions, but for instance the argument list will be
different, or the implementation has a bug, etc.  (I'm thinking of
ConfigParser and SMTP...)

I really *do* want to require a specific version or higher.  It's the
'or higher' part that's hard...

Spasibo,
---Preston

In article <Pine.LNX.4.21.0003021732340.1119-100000 at fep132.fep.ru>,
  phd at phd.russ.ru wrote:

>    Do not check version - this will bound poor user to one version.
Check
> for the feature you need. You need a library? Try to import it and
fall
> back gracefully:
>
> try:
>    import pagecast_lib
> except ImportError:
>    print_error()
>
> if not pagecast_lib.has_key("I_need_IT"):
>    print_another_error()

--
|| Preston Landers <prestonlanders at my-deja.com> ||


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list