So, what's the real story on Python 2 vs Python 3?

Chris Angelico rosuav at gmail.com
Fri Dec 27 01:00:39 EST 2013


On Fri, Dec 27, 2013 at 4:43 PM, Rustom Mody <rustompmody at gmail.com> wrote:
> 1. print: Use print with (). Dont use funny 2 syntax
> 2. Always write strings with a u" prefix
> 3. Always use new style classes
> 4. Always use relative imports with explicit relative (ie use .)

Even easier:

1. from __future__ import print_function
2. from __future__ import unicode_literals
(3 and 4 as per your above)

For anything 2.6 or newer, those two will give Py3 behaviour, at least
in those two ways. Saves you having to put the explicit u prefix on
everything.

ChrisA



More information about the Python-list mailing list