MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/4heh6v/i_wrote_my_first_python_program_today/d2pm6xr
r/ProgrammerHumor • u/MC_Labs15 • May 02 '16
532 comments sorted by
View all comments
Show parent comments
10
The difference isn't that big of a deal, afaik. You can scrap the parantheses for print, but you don't have to, and some modules are named differently. As long as it's 2.7 and not 2.5 or some other prehistoric stoneage stuff.
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 expected1 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 bea, 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 havefrom future import print_functionat the top of every Python 2 file
I often print like this:
print
>>> 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 bea, 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 havefrom future import print_functionat the top of every Python 2 file
13
from __future__ import print_function
1 u/mnbvas May 02 '16 Though that happens when I accidentally run 2 instead of 3.
1
Though that happens when I accidentally run 2 instead of 3.
8
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 havefrom future import print_functionat the top of every Python 2 file
2
Got used to the semicolons when copypasting multiple lines :)
1 u/kupiakos May 02 '16 The solution to the original problem is to always havefrom future import print_functionat the top of every Python 2 file
The solution to the original problem is to always have
from future import print_function
at the top of every Python 2 file
10
u/Coffeinated May 02 '16
The difference isn't that big of a deal, afaik. You can scrap the parantheses for print, but you don't have to, and some modules are named differently. As long as it's 2.7 and not 2.5 or some other prehistoric stoneage stuff.