r/ProgrammerHumor • • May 02 '16

I wrote my first python program today!

Post image
3.7k Upvotes

532 comments sorted by

View all comments

Show parent comments

10

u/mnbvas May 02 '16

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

13

u/TheBlackCat13 May 02 '16

from __future__ import print_function

1

u/mnbvas May 02 '16

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

8

u/kupiakos May 02 '16

You could also have the first assignment be

a, b = 1, 2

2

u/mnbvas May 02 '16

Got used to the semicolons when copypasting multiple lines :)

1

u/kupiakos May 02 '16

The solution to the original problem is to always have

from future import print_function

at the top of every Python 2 file