another approach here would be to use:

rpm --eval %{fedora}

something like this:

fp = os.popen('rpm --eval %{fedora}')
fedora_version = fp.read()
fp.close()
if int(fedora_version) >= 18:
  blabla