backwards-compatibility

Jason Swails jason.swails at gmail.com
Tue Mar 1 08:47:59 EST 2011


> 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".
>

Ah; I didn't quite see how something in subpackage1 would know to look up a
directory to see if it was in another package (I thought I would have to
play games with PYTHONPATH).  Works like a charm though.  Thanks!


>
> > 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 :
>

Ah, great.  And it also works for python2.6 and 2.7.


> > Is there any way of rewriting this so I can still print the error message
> in
> > python2.5/2.4?
> > <http://mail.python.org/mailman/listinfo/python-list>
>

Many Unix OSes (especially on supercomputers) have painfully out-of-date
system python versions, so unfortunately I have to maintain compatibility
with these super old versions.

Thanks again!
Jason

-- 
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Candidate
352-392-4032
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110301/a552d3c6/attachment.html>


More information about the Python-list mailing list