Search code examples
pythonpython-2.7python-3.xversion-controlsix

Python 2+3 compatible code: Should I avoid six?


This guide, Writing code that runs under both Python2 and 3, states that

Use the third party six module sparingly (i.e. only if necessary). One good use case is the reraise() method.

Why is this? I thought the whole point of six was to make Python 2+3 compatible code easier.


Solution

  • I think the point is to try and avoid 2/3 specific constructs where possible, and only employ things like six when you have no other native option - as it adds complexity and additional fault points to the code. Since six is faking some stuff to bridge the gap, you may find it doesn't always work exactly as intended.