r/Python • • May 30 '19

Dear python2 user

Post image
1.9k Upvotes

275 comments sorted by

View all comments

56

u/captain_cashew May 30 '19

My company is moving from 2.6 to 2.7! Yay!

32

u/PooPooDooDoo May 30 '19

print “yay!”

31

u/regeya May 30 '19

I went into a local company to do some contract work, and found out not only are they still using Visual Basic 6, they were talking about moving to VB.net someday. They wanted a static website to be built, but only if I could build it in a specific piece of discontinued Adobe software, and another website to be modernized that was built in Google Sites.

I just pretended that meeting never happened.

12

u/alcalde May 30 '19

That was me at Bed Bath and Beyond HQ in 2005, when I encountered Access 97 and Impromptu 5 (Impromptu had been discontinued at version 8). They were also using VB6 for internal development. I stayed six months.

2

u/regeya May 31 '19

Scarily enough, the one I'm thinking of deals with court documents.

10

u/i9srpeg May 30 '19

Are you enjoying your fancy new dict comprehensions?

11

u/captain_cashew May 30 '19 edited May 31 '19

Your comment comes at a very appropriate time. Literally just a few minutes ago found a bug on one of our systems using 2.6 (my local development station is on 2.7):

{k: v for (k, v) in dict.items()}

You have to use:

dict((k, v) for (k, v) in dict.items())

So, yes I am enjoying them!

EDIT: code format

2

u/flying-sheep May 31 '19

If a thing has an items method, you can just do dict(thing) to create a dict copy. If it’s a dict, you can do the_dict.copy(). You only need comprehensions if you have to construct keys and values in a more complex way.

1

u/nieuweyork since 2007 May 31 '19

To me this is an argument against the Python developers' increasingly profligate addition of syntax. There's almost never one obvious way to do it these days.

5

u/gruey May 30 '19

I still think that it was a huge mistake from Python not to just bite the bullet and create some kind of Python 2-3 interpreter like a decade ago when it became obvious there was just too much momentum against moving to 3.

Basically something that'd let you mark it and all of its dependencies as 2.7, do some fairly thorough translation that gets 99.8% of the existing code and ideally warning about things it felt it couldn't translate. Some performance loss would be acceptable. A flag could be given to print warnings for anything that wasn't 3.

It didn't have to be perfect, it just had to allow a company to start writing new stuff in 3 only having to modify a few things without having to touch their entire code base. They could then also start incrementally porting things to Python 3 without having to make sure they do everything and their external dependencies at once.

It isn't ideal, but I really, really feel like despite Python's progress over the last decade, it would have been significantly more if all the effort was on Python 3 and all the new features of Python 3 were available to the majority of the Python users. I wonder how many companies switched from Python 2 to golang or similar for features or performance that would have been acceptable in Python 3?

5

u/[deleted] May 31 '19

IMO the difficulty of migrating to 3 was just way overblown. They didn't need to create anything like that. They should do what everyone else is doing and give a year to migrate (not 10). Everyone waited to last minute to start the migration.

1

u/3waysToDie Jun 10 '19

very true

7

u/TBSchemer May 30 '19

2to3.py gave companies a way to easily migrate their code to 3. The ones who didn't really have no excuse at this point.

6

u/gruey May 30 '19

2to3.py is not even close to enough of a solution for significant code bases.

The ones who didn't migrate have pretty valid business reasons for not having done it yet. Basically, what it comes down to, Python's value in companies moving to 3 was greater than most companies value of moving to 3, so Python should have done more work to make it happen.

9

u/TBSchemer May 30 '19

They had 10 years to do it. Most did. The rest didn't out of hubris.

4

u/data-punk May 30 '19

What valid reason spans delay over a decade?

6

u/billsil May 31 '19

It took 10 years for wxpython to officially support 3.x. I moved onto PySide, but not other people.

1

u/nieuweyork since 2007 May 31 '19

I very much agree. A from __future__ import py3hosting or something, to restore python2.7 semantics for the things that were incompatibly changed. That plus from __future__ import print_functionwould have handled a lot of cases.

1

u/ALonelyPlatypus Jun 28 '19

wait. companies switched from python2 to go to avoid python3? I mean go is relatively feature rich and overall fun to code but I couldn’t imagine converting your python2 codebase to it when python3 exists.

(unless the company already wanted to move over to a compiled language to address performance concerns)

2

u/billsil May 31 '19

That’s still better. Take what you can get. I upgraded a 2.4 project to 2.7 last year. I just removed hacks and fixed some bugs I created by hacking a 3rd party library to make it work in 2.4.

I just decided to start using 3.7, even if other people continue to use 2.7. I’ll support it if I have to, but I’m going to make sure 3.7 works.

1

u/zabolekar Jun 13 '19

Maybe even to 2.7.16!

0

u/confusedpublic May 30 '19

Me too, free upgrade from 14.04 to 18.04!