Re: need help updating imgsizer for python2.1
On Tue, Jan 08, 2002 at 06:51:44AM -0500, dman wrote:
> I'd prefer to write this as
>
> try :
> import filecmp as cmp
> except ImportError :
> import cmp
>
> It is more pythonic to just try to do what it is you want, and handle
> the situation when it fails, than it is do try and figure out what is
> write and do only that which works.
Except that in this case, versions of python before 2.0 will give a
SyntaxError, because "import spam as eggs" is a new feature as of 2.0.
To be backwards compatible, use:
try:
import filecmp
cmp = filecmp
del filecmp
except ImportError:
import cmp
-Andrew.
Reply to: