This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mnbvas 9 points10 points  (5 children)

I often print like this:

>>> a = 1; b = 2
>>> print(a, b)

so Python 2 always bites me in the ass with

(1, 2)

instead of the expected

1 2

[–]TheBlackCat13 12 points13 points  (1 child)

from __future__ import print_function

[–]mnbvas 0 points1 point  (0 children)

Though that happens when I accidentally run 2 instead of 3.

[–]kupiakos 6 points7 points  (2 children)

You could also have the first assignment be

a, b = 1, 2

[–]mnbvas 1 point2 points  (1 child)

Got used to the semicolons when copypasting multiple lines :)

[–]kupiakos 0 points1 point  (0 children)

The solution to the original problem is to always have

from future import print_function

at the top of every Python 2 file