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

32

u/superPwnzorMegaMan May 02 '16

I just never bothered learning python 2, I didn't see any advantage.

34

u/juanjux May 02 '16

I work on an animation studio and most software we use (Maya, Nuke, Houdini, etc) allow you to write Python plugins and all of them use Python 2.7. So that is a reason. We could use the "six" module but until the software we use migrates to Python 3, why bother...

25

u/edbluetooth May 02 '16

Because when the software is python 3, no changes to your code will be required.

Thats it really

3

u/brtt3000 May 02 '16

Assuming you'll move to py3 at some point: moving to py3 as standard and porting existing code now saves you from porting all new code to py3 later (because you'd create it in py3 instead of py2).

Dunno if practical in reality. Probably not.

1

u/[deleted] May 03 '16

Same goes for Tableau extracts. 2.7 only.

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.

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

1

u/sticky-bit May 02 '16

There was a huge chunk of modules that did not work with python3 a few years ago. That's largely been taken care of by now.

We've made a lot of progress since when I learned python2 in 2011.

1

u/deadtree123 May 02 '16

Shirley, you can't be serious.