I'm trying to write a forward compatible program and I was wondering what the "best" way to handle the case where you need different imports.
In my specific case, I am using ConfigParser.SafeConfigParser()
from Python2 which becomes configparser.ConfigParser()
in Python3.
So far I have made it work either by using a try-except on the import or by using a conditional on the version of Python (using sys
). Both work, but I was wondering if there was a recommended solution (maybe one I haven't tried yet).
ETA:
Thanks everyone. I used six.moves
with no issues.