Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46691 > unrolled thread

Python 2-3 compatibility

Started byJason Swails <jason.swails@gmail.com>
First post2013-06-02 10:13 -0400
Last post2013-06-02 10:13 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Python 2-3 compatibility Jason Swails <jason.swails@gmail.com> - 2013-06-02 10:13 -0400

#46691 — Python 2-3 compatibility

FromJason Swails <jason.swails@gmail.com>
Date2013-06-02 10:13 -0400
SubjectPython 2-3 compatibility
Message-ID<mailman.2542.1370182425.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hello Everyone,

I have a Python script that I wrote to support a project that I work on
(that runs primarily on Unix OSes).  Given its support role in this
package, this script should not introduce any other dependencies.  As a
result, I wrote the script in Python 2, since every Linux currently ships
with 2.4--2.7 as its system Python (RHEL 5, still popular in my field,
ships with 2.4).

However, I've heard news that Ubuntu is migrating to Python 3 soon (next
release??), and that's a platform we actively try to support due to its
popularity.  I've tried writing the code to support both 2 and 3 as much as
possible, but with priority put on supporting 2.4 over 3.

Now that Python 3-compatibility is about to become more important, I'm
looking for a way to catch and store exceptions in a compatible way.

Because Python 2.4 and 2.5 don't support the

except Exception as err:

syntax, I've used

except Exception, err:

Is there any way of getting this effect in a way compatible with Py2.4 and
3.x?  Of course I could duplicate every module with 2to3 and do
sys.version_info-conditional imports, but I'd rather avoid duplicating all
of the code if possible.

Any suggestions are appreciated.

Thanks!
Jason

-- 
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Candidate
352-392-4032

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web