backwards-compatibility

Benjamin Kaplan benjamin.kaplan at case.edu
Sat Feb 26 17:32:26 CET 2011


On Sat, Feb 26, 2011 at 8:11 AM, Jason Swails <jason.swails at 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 :

> Is there any way of rewriting this so I can still print the error message in
> python2.5/2.4?
>
> Thanks!
> Jason
>
> --
> Jason M. Swails
> Quantum Theory Project,
> University of Florida
> Ph.D. Candidate
> 352-392-4032
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



More information about the Python-list mailing list