On Nov 05, 2012, at 06:04 PM, Nick Coghlan wrote:
Even better (http://packages.python.org/six/#package-contents):
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.