Importing Version Specific Modules

M

Michael Crute

Which method makes the most sense for importing a module in python
that is version specific? My use case is that I'm writing code that
will be deployed into a python 2.3 environment and in a few months be
upgraded to python 2.5. This:

if sys.version_info[:2] >= (2, 5):
from string import Template
else:
from our.compat.string import Template

or this

try:
from string import Template
except ImportError:
from our.compat.string import Template

I know that either case is equally correct and works correctly but
which one is preferable?


--
________________________________
Michael E. Crute
http://mike.crute.org

God put me on this earth to accomplish a certain number of things.
Right now I am so far behind that I will never die. --Bill Watterson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top