faqts : Computers : Programming : Languages : PHP : Common Problems : Files : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

31 of 40 people (78%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I check that the Python version is recent enough to run my program?

Jul 1st, 2008 11:37
sheana krat, Nathan Wallace, Fredrik Lundh, Oleg Broytmann


Note that [1, 5, 2] < [1, 6].  in other words, this will do what you
want:
  import string, sys
  version = string.split(string.split(sys.version)[0], ".")
  if map(int, version) < [1, 5, 2]:
    print "sorry"
I can be better to not check the version - this will bound poor user to
one version. Instead, 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()
http://www.indianhandicraftsexporters.com
http://www.topgiftsideas.com
http://www.eindianweddingcards.com