7 ms·
Thanks for the reply. Are there any guidelines or "best practices" for writing code for both 2.7 and 3.4?
by nullflow 12y ago
Thanks for the reply.
Are there any guidelines or "best practices" for writing code for both 2.7 and 3.4?
- Macha 12y agohttp://python-future.org/compatible_idioms.html http://python-future.org/compatible_idioms.html This is a pretty comprehensive guide. It does rely on the future lib, which is a wrapper around six and a few others to make it easier, but you can also just write your own minimal lib for things that need to have: if py2: pass # Py2 specific line here else: pass # Py3 stuff here I think Django has chosen the approach of having their own minimal compatibility layer, iirc.
- ubernostrum 12y agoHere is Django's documentation, including notes on the compatibility stuff we ship: https://docs.djangoproject.com/en/1.7/topics/python3/ https://docs.djangoproject.com/en/1.7/topics/python3/