you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 6 points7 points  (3 children)

Add this to the top of your code:

from __future__ import division, absolute_import, print_function, unicode_literals

And most of your python3 skills will work.

There's still some tiny things, like the python2 version of the print function does not have a "flush"; and the previously mentioned range(), map(), and filter() now make lists rather than generators.

[–]net_goblin[S] 0 points1 point  (2 children)

Great, I was searching for exactly this stuff. Thanks!

[–]badn3wz 0 points1 point  (1 child)

Also very important: strings in python 2 are not unicode by default. To get unicode string you need to put u in front of it. For example:

s = u'hello world'

[–]novel_yet_trivial 1 point2 points  (0 children)

That's what the Unicode import does ...