On Nov 6, 2012 2:12 AM, "Barry Warsaw" <barry@python.org> wrote:
On Nov 05, 2012, at 06:04 PM, Nick Coghlan wrote:
Even better (http://packages.python.org/six/#package-contents):
import six
if six.PY3: # Ooh, Python 3 else: # Not Python 3
If anyone is trying to do single code base Python 2/3 support without relying on six, they're doing it wrong. Even bundling a copy (if you don't want to deal with dependency management issues) is a better idea than reinventing that wheel.
If you *are* rolling your own (or need additional compatibility fixes that six doesn't provide), then all Python 2/3 compatibility hacks should be located in a small number of compatibility modules. They *shouldn't* be distributed widely throughout your codebase.
While I agree with the sentiment, and also agree that six is an excellent package that can be very useful, I'll just point out that it's often very possible and not at all painful to write to a single code base without
using
it. It all depends on what your code does/needs.
True, my own 2/3 compatible projects don't use it, but they also don't have any significant special cases for either version. I guess stick a "for non-trivial cases" qualifier in there somewhere :) Cheers, Nick. -- Sent from my phone, thus the relative brevity :)
Cheers, -Barry
_______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas