On 2/26/2011 11:32 AM, Benjamin Kaplan wrote:
On Sat, Feb 26, 2011 at 8:11 AM, Jason Swails<jason.swa...@gmail.com>  wrote:
Hello,

I have a question I was having a difficult time finding with a quick google
search, so I figured someone on here might know.  For the sake of backwards
compatibility (and supporting systems whose default python is OLD), I'd like
to rewrite some code to be compliant with Pythons as old as 2.4.  For this
reason I've already had to do away with all "{1}".format(item), but I'm
running into new problems with the packages I've written.  For instance, I
have a package "package1" with "subpackage1".  One of the modules in
subpackage1 imports the exceptions module from package1, and I do that like
this:

from ..exceptions import MyException


You'll have to import that using the absolute import. It would be
"from package1.exceptions import MyException".

Which is perfectly fine by python2.5, 2.6, and 2.7; but unacceptable in
python2.4.  Any thoughts?

Another python2.6 feature I'm using is

except Exception as err:
    print err


except Exception, err :

Of course, this breaks compatibility with 3.x without running through 2to3. You did not specify how far forward you want to cater to.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to