On Thu, Dec 4, 2008 at 7:33 PM, <[EMAIL PROTECTED]> wrote:
>Michael> try:
>Michael> from string import Template
>Michael> except ImportError:
>Michael> from our.compat.string import Template
>
> This is "easier to ask forgiveness than permission" (EAFP). This tends to
> be
Michael> if sys.version_info[:2] >= (2, 5):
Michael> from string import Template
Michael> else:
Michael> from our.compat.string import Template
This is "look before you leap" (LBYL).
Michael> try:
Michael> from string import Template
Michael> except Import
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 Templ