r/Python • • May 30 '19

Dear python2 user

Post image
1.9k Upvotes

275 comments sorted by

277

u/billsil May 30 '19

I killed my libraries support for python 2 last Friday. It feels good to get rid of six, future, scans it, and pathlib2 and really start doing type annotations properly.

People are already trying to get me to change my mind. But my company uses Anaconda...use a virtual environment; Anaconda lets you have multiple versions of python. It’s coming like a train and all my dependencies have moved on. Time for me to as well.

59

u/jftuga pip needs updating May 30 '19

Link to your project?

0

u/[deleted] May 30 '19

[deleted]

6

u/darthwalsh May 30 '19

In general, that would identify their reddit username (but I have no idea if OP here is already public).

3

u/billsil May 31 '19

My account name is my name, so yeah, no. It’s not even me plugging the project, nor would it be interesting to 99.9% of people here.

-70

u/mmarius90 May 30 '19

In total agreement with you except for the type annotations. I see those as an abomination. Python is so beautiful as a syntax without those horrible glyphs.

Quote the PEP:

While these annotations are available at runtime through the usual annotations attribute, no type checking happens at runtime . Instead, the proposal assumes the existence of a separate off-line type checker which users can run over their source code voluntarily

See? An abomination. I'll never introduce those in my personal projects.

57

u/rouille May 30 '19

The whole point is that you can, optionally, do static type checking. And it works very well in practice.

50

u/billy_tables May 30 '19

They're optional, and super useful to many people. Far from an abomination, just not useful to you

20

u/cglacet May 30 '19

I fail to see what you "see" in this quote. I personally don't use type annotation in my current python project, but it's only due to the nature of what I'm doing. It's probably your case too and that's why you fail to see why it can be useful to have static type checking. But in many cases, adding types is fast and simple, it serves as a documentation, helps autocompletion and saves you a lot of debugging time (because you will obviously have less typing errors). The best part is: it's optional, so you can very well add types to sensitives part of your code (low level, widely used code) and leave high level functions signatures untyped and documented them using docstrings.

Have a look at the javascript (ECMAScript) community and you'll see that many people are using flow or typescript annotations, even tho it's not as clean as mypy+python because it requires transpilation (in order to remove annotations and get the javascript code back to standard).

7

u/[deleted] May 30 '19

Maybe they aren't as useful as they could be, but how else could you write typed code without a performance penalty?

If you checked type at runtime everything would slow to a glacial crawl...

→ More replies (9)

7

u/energybased May 30 '19

Before type annotations, I used to have a lot of comments explaining the types of various parameters and variables.

2

u/teilo May 30 '19

Aside from the personal preference issue, when working on a complex code base with a team, they are invaluable. It makes the code self-documenting by only viewing a function declaration.

→ More replies (3)
→ More replies (4)

132

u/SketchyMikePemulis May 30 '19

print("good riddance")

75

u/Zomunieo May 30 '19 edited May 30 '19

from __past__ import print_statement

print "glad this is gone?" >> sys.stderr

21

u/shiny-tyranitar May 30 '19

You have some unnecessary parentheses there pal

Wait...

75

u/alcalde May 30 '19 edited May 30 '19

OK, where's the person here who keeps telling me that the PSF is definitely going to extend the deadline again?

25

u/blitzkriegger May 30 '19

ahh, the Python Safety Federation...../s

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!

58

u/hopeinson May 30 '19

Now that you have heard of Python 3, now get ready for Python 4! [/s]

But seriously, we need to start moving on from Py2. It's a dead horse meat now.

17

u/nooobmaster-69 May 30 '19

Python 4 is already mentioned in the timelines for many of the changes. But not to worry, it will be much less of an issue migrating from 3->4 than it was from 2->3.

24

u/Rodot github.com/tardis-sn May 30 '19

That's because Python 4 is just going to be Python 3.10, that's just how they are going to continue with versioning

16

u/flying-sheep May 30 '19

That’s what Guido said a while back, I hope the new guidance council doesn’t share this view and just release 3.10, 3.11, …

1

u/billsil May 31 '19

Guido is on the council and was the top vote getter by 30% or so. He was the only council member that got over 50% and cleared that easily. He's quite popular among the core devs.

6

u/flying-sheep May 31 '19

Yes, but I think this is a case he doesn’t feel strongly about but that he still considered his decision / matter of taste when he was BDFL. And such cases will now be voted on, and if the others say “not doing semver is confusing and people will be scared by upgrading to 4.0” there won’t be strong arguments against that.

→ More replies (5)
→ More replies (2)

1

u/bageldevourer Jun 01 '19

This isn't necessarily true according to the latest episode of Talk Python.

7

u/tr14l May 30 '19

I have to assume that Py4 will be largely non-breaking. They have to have learned their lesson....right?

10

u/AusIV Django, gevent May 30 '19

If you're following Sem Ver (which I'm not sure if Python claims to do) then you wouldn't go to 4 unless you were breaking something. I'd hope that the version that comes after 3.9 will just be 3.10 if it's backwards compatible. If they go to 4, they will be introducing breaking changes for all the people who use python3 to run their code.

9

u/twelveshar May 30 '19

Python does not follow SemVer; it allows breaking changes in "minor" versions, like 3.7 -> 3.8. See the development cycle page: https://devguide.python.org/devcycle/

→ More replies (1)

6

u/cerin_2 May 30 '19

RIP in pieces those of us using jython which hasn't caught up to 3.

-6

u/[deleted] May 30 '19

[removed] — view removed comment

24

u/emuccino May 30 '19

"Catastrophe" is a bit dramatic

3

u/alcalde May 30 '19

You'd be surprised. OpenSUSE Linux had a discussion about version numbering a few years ago. They used to go X.0, X.1, X.2, X.3 and then increment by 1 and continue. There was no meaning to the numbers, but it seems casual users didn't know that. Apparently people assumed that a .0 release was a major release and decided to wait for a .1 release to "work out the bugs". Point zero releases were actually showing half the downloads compared to other releases! Not only that, tech sites seemed to think the same way, as reviews of non-point zero releases were lower compared to point zero releases.

They finally decided to drop point zero releases entirely. (They made a lot of other, dumber, numbering ideas later on, like going from 13.4 to 42 and then to 15, but that's another story).

2

u/cyanydeez May 30 '19

numbering in general is just a dumb human thing.

I think we should just give everything flavors and colors

→ More replies (1)

0

u/[deleted] May 30 '19

[removed] — view removed comment

3

u/zardeh May 30 '19

Yeah but they've had years. Python 3.5 has been out for 4 years. It'll EOL before Py4 comes out. That's enough time to upgrade, especially if the upgrade isn't back-breaking.

1

u/billsil May 31 '19

I’m still waiting for the python 2.8 fork....there are two versions of Perl 6.

1

u/Intrexa May 30 '19

I propose 3.91, 3.92

14

u/[deleted] May 30 '19

I have been working in 3.x exclusively now for some years, but I recently took out support for 2.x from a couple of old libraries and it was like getting a little stone out of my shoe.

Interestingly 3.4 is now a slight pain point - there are a couple of CI tools like mypy that are only available for Python 3.5 onwards. In new development, I don't support 3.4, but I haven't yet removed it from old libraries that have existing users because why make their lives miserable? 3.4.10, the final version of 3.4, has only recently been released...

15

u/PeridexisErrant May 30 '19

3.4 reached end of life in March, so there are no more security updates for it and many libraries have already dropped support.

1

u/billsil May 31 '19

You sure about mypy? Python 2.7 is supported and you can always run mypy with 3.5. There is no reason other than very minor issues that you couldn’t run mypy. Doesn’t mean other people have to upgrade.

1

u/[deleted] May 31 '19

mypy requires 3.5+ checking 2.7 code requires you to specify python interpreter in arguments for the checked version so it knows how to find packages. Perhaps 3.4 could be tested in a similar way, I never did that though.

1

u/edbluetooth May 31 '19

The only reason I run tests for 3.4 is that my customers use Windows XP in many cases.

I agree with 3.5 onwards not supporting XP, but it is a bit of a pain in some situations.

22

u/acerbusbellum May 30 '19

Well unfortunately until the DCC's (Maya, Nuke, Houdini) and our project management system (shotgun) change the interpreters to py3 we'll be such with it.

Has anyone seen much about what Autodesk, Foundry, etc have said about support for py3?

14

u/uberdavis May 30 '19

As I understand, Maya can be run using Python 3. One of my workmates told me there’s a sneaky configuration setting.

1

u/acerbusbellum May 30 '19

Interesting... I'll have to look that up. Do you know what version of Maya your colleague is using?

1

u/uberdavis May 30 '19

I’ll ask and get back to you. I’ve just upgraded myself and would be keen to know.

7

u/JezusTheCarpenter May 30 '19

Eventually all those products will have to switch to Python 3 so I wouldn't worry about it that much. I know they are thinking about it.

4

u/mragi May 30 '19

Coming next year: https://vfxplatform.com/

2

u/acerbusbellum May 30 '19

Interesting :-)

Thanks for the link

5

u/Emile_L May 30 '19

This, pretty much. We're not using Python2 because we want to

27

u/mrrichardcranium May 30 '19

Just started using python. Learned python 2 because of the systems and frameworks I’m using at work. This last week I started moving all things possible to python 3 in anticipation for it becoming the default on coming OSs. Holy hell does it make a lot of things easier. Basic threading in 3 makes me wish I could rewrite the frameworks my work uses so I could make the full jump over and never look back.

13

u/toyg May 30 '19

Basic threading

You mean asyncio, I guess? It's not really "threading"...

13

u/mrrichardcranium May 30 '19 edited May 30 '19

I mean splitting up a list of 700+ items to 10 workers using threadpoolexecutor. Maybe ‘basic threading’ is not the right description. The fact that it took me two lines to get done is what makes me think of it as basic 😅

7

u/toyg May 30 '19

Ah, good point, I forgot concurrent.futures is 3-only...

5

u/mrrichardcranium May 30 '19

And god damn is it glorious!

3

u/TBSchemer May 30 '19

Your workplace definitely needs to hire someone to rewrite those frameworks within the next 6 months.

1

u/mrrichardcranium May 30 '19

If I was a betting man, I would be willing to wage an entire years salary that there are people doing just that. Its a critical automation framework that I don't think we can afford to function without. Though Im sadly not disclosed on the status of that just yet.

32

u/purestrengthsolo May 30 '19

What exactly is "end of life" like programs will no longer work or is it just not receiving any kind of updates?

104

u/joesb May 30 '19

No update.

35

u/Losupa May 30 '19

It can mean a variety of things typically it means that there will be very little to no more updates on python 2 libraries, which most importantly means there are no security updates, and thus certain online programs will become unsafe.

60

u/Barafu May 30 '19 edited May 30 '19

It means that very soon after that some security vulnerability will be published, and applications like Calibre or Deluge will become malware hosts if they don't switch to Py3 by then.
Also, they will be kicked out of Linux default repositories.

8

u/purestrengthsolo May 30 '19 edited May 30 '19

Thank you and everyone else who replied to me, it helped clarify a little better

8

u/Cardeal May 30 '19

Wasn't Calibre going to be being ported? WIP: Port calibre to python 3

2

u/Dgc2002 May 31 '19

kovidgoyal

Oh god I forgot about that developer. I wish I had the list of links to his shenanigans on hand to provide as context but I don't.

2

u/Cardeal Jun 02 '19

Yeah, I am aware. But I am betting he will port it to python3. He needs the spotlight.

1

u/toyg Jun 03 '19

The guy can be “special” but it’us undeniable that he’s done a lot for the ebook community over the years, and for free.

1

u/_b-e-n_ Jun 21 '19

He's quite annoying, but that software is really good. A fantastic work. That and Alf's tools :-))))

→ More replies (3)

6

u/tr14l May 30 '19

They stop receiving support, so they break slowly over time. Mirrors start becoming more and more seldom found. Then police come to your door and watch you refactor your code.

2

u/3waysToDie May 30 '19

The future you see

3

u/nukem996 May 30 '19

No updates or support from python.org, this includes security fixes. Some OS vendors(RHEL, Ubuntu, SUSE, etc) will continue to support Python 2.7 in their OS for security fixes until their product goes EOL. A previous job I had refused to put any resources into migrating to Python 3 because they're on RHEL7 which will receive support until 2024 :\

2

u/AlexFromOmaha May 30 '19

Has Red Hat confirmed support for Python 2.7 in userland, instead of just support for the OS's internal security?

2

u/buttery_shame_cave May 30 '19

they're going to finally stop backporting all the good stuff from 3 to 2.

2

u/[deleted] May 31 '19

They stopped that in 2015, that's when python 3, that was the hump year for python 3. Could be a coincidence, but I don't believe in those. from 2015-2020 python 2.7 only gets security fixes.

1

u/cyanydeez May 30 '19

security is no longer a supported feature.

→ More replies (8)

14

u/NAN001 May 30 '19

You're telling me there is money to be made maintaining a safe version of Python 2.

9

u/kyrsjo May 30 '19

There probably is, however I would expect RedHat etc. will be on it since they anyway need to support RHEL distros which depend on having safe Python2 for quite a few more years.

4

u/james_pic May 30 '19

Yes. Several vendors (RedHat and ActiveState being the best known) are already offering this.

1

u/[deleted] May 30 '19

like php5.6

9

u/batisteo May 30 '19

Maybe it’s time to update the PEP 394? https://www.python.org/dev/peps/pep-0394/

When Guido is yelling to not use python2 and an official PEP is telling us that python is python2, then it’s hard to not confuse people.

Time to break unmaintained admin scripts guys.

2

u/cyanydeez May 30 '19

you mean it's time to maintain the unmaintained.

24

u/[deleted] May 30 '19

To everyone who could not be arsed to look at the Python 2 to 3 update guides for the past however many years: Stop it. Get some help.

8

u/[deleted] May 30 '19

I was encouraged to learn 2.7 and stick with it over 3 about 3 years ago and aside from the print statements I can’t really figure out what’s different (I’m not a programmer; I use it for data analysis, image processing in astronomy, and playing around). What are some of the big differences between 2 and 3, in the language of non-CS people?

7

u/[deleted] May 30 '19

There are lots and lots of massive changes that occurred from 2 to 3. New libraries, new builtins, syntax changes, more consistent naming, etc. But in my opinion, the biggest change was from eager evaluation to lazy evaluation.

The easiest example is range. In python 2, range creates a list of integers before executing the next line. This potentially slows the runtime down immensely if the number is large enough. Python 3 changes that by only adding to the list when it reaches that point. This removes that upfront cost, and in general speeds up the program.

9

u/alcalde May 30 '19

New libraries, new builtins, syntax changes, more consistent naming, etc. But in my opinion, the biggest change was from eager evaluation to lazy evaluation.

Fascinatingly you completely left out the Unicode string change, which is usually cited as the major change. :-)

2

u/[deleted] May 31 '19

It was actually THE change that broke python 2 code (actually to be correct most python 2 code is broken, python 2 just didn't complain about it). Basically if you have python 2 code chances are that it will mess up unicode text.

The other incompatible changes were because of it. They thought that since compatibility was broken anyway, why not just use that as an opportunity to cleanup the language.

1

u/[deleted] May 30 '19

Would you please explain that?

5

u/billsil May 31 '19

The only painful change about Python 3 is how unicode is handled. The tutorials still suck and nobody tells you even how to figure out what encoding you have. The reality is that user files are in a variety of encodings and they don’t even know what that is.

No other change about python 3 is even worth discussing when planning/worrying about the transition to python 3.

2

u/icegreentea May 31 '19

I think you can add the bytes/str split (which is closely related to the unicode handling). Any code base in python2 that was using str type to represent bytes is in a world of pain converting to python3.

5

u/billsil May 31 '19

That’d be fine. It’s when you’re inconsistent that the pain really sets in. Python 2 did weird ass shit by flipping the encoding multiple times, so you had to encode when you got a decode error and vice verse. Then when you print it, it wouldn’t print correctly even when you had done things right. Python 3 fixed that.

1

u/regeya May 30 '19

Yeah, range() behaves more like xrange() now. Parens in print statements can be annoying after being used to not using them, but it helps with clarity imho.

4

u/TBSchemer May 30 '19

Holy hell, you're using 2.7 for image processing? Whoever "encouraged" you to stick with it should be locked away.

Anything involving big data is far more efficient in 3, because of the switch to lazy evaluation of iterators. Also notably, numpy and everything based on it (pandas, scikit, etc.) have already discontinued support for 2.

3

u/[deleted] May 31 '19

Well, the good news is I misremembered, and that particular professor teaching image processing insisted on 3!

5

u/[deleted] May 30 '19 edited May 30 '19

You can always use the fork from the guy who made Calibre, whatever that is.

8

u/alcalde May 30 '19

It turns out Calibre is even doing work now to ready it for Python 3, so I think Kovar finally saw the light.

1

u/[deleted] May 30 '19 edited May 30 '19

Cool!

But I honestly believe Python 2 will be forked to death and at least one of its variants will be supported for more 20 years (programmers are a stubborn kind :P).

2

u/alcalde May 30 '19

2

u/[deleted] May 30 '19 edited May 31 '19

I find Calibre useful, wonderful and misguided all at the same time. I never wanted an "iTunes for ebooks" (who does?) but I must put up with it in order to convert my files...

2

u/Gorian May 31 '19

I don't want "iTunes for eBooks" but I do want "Plex for eBooks"!

→ More replies (3)

1

u/[deleted] May 31 '19

I doubt it, python 3 is past the hump and actually python 2 are minority, major packages already stopped supporting 2.

There was also a fork initially called python 2.8, it was renamed since then and it didn't go anywhere.

Edit: https://github.com/naftaliharris/tauthon I was wrong, still exists, so we'll see. As a person who moved to python 3 I don't understand the stubbornness of being on 2.x, a lot of language was cleaned up in 3 and it is much more enjoyable to program in 3.

1

u/toyg Jun 03 '19

I wouldn’t touch Tauthon with a barge pole. Official CPython comes with well-defined governance model, support guarantees, oversight, upgrade paths, security, and so on. Tauthon is literally “a bunch of people on github”. If your business depends on something so critical that you can’t spend a few weeks porting it to 3.6+ and would rather rely on random patches from the internet, you are in trouble.

11

u/whitechapel8733 May 30 '19

My problem with this is that lots of distros are shipping python 2 still.....

65

u/mikew_reddit May 30 '19 edited May 30 '19

Python 3 has been in development over 10 years (since 2008).

It's perfectly fine to cut the cord after a decade.

 

If CentOS and other distributions can't be bothered to update, that's not really Python's fault.

 

Edit: original EOL was 2015 according to Guido. Also, Python 2.7 will not get security updates after Jan 1st, 2020.

9

u/whitechapel8733 May 30 '19

I agree, but I’m just saying that’s a serious concern.

31

u/tomanonimos May 30 '19

But a necessary pain. If we keep pushing it for that fear we'll never get rid of Python 2 lol.

2

u/nukem996 May 30 '19

Python.org won't issue security fixes but OS vendors like RHEL/CentOS will continue to patch Python 2.7 themselves.

4

u/alexbuzzbee May 30 '19

I'm pretty sure CentOS is going to Python 3 with RHEL in version 8.

0

u/liquidpele May 30 '19

Which isn’t even close to being released yet. Maaaaybe around December if it takes the same amount of time after rhel7.

5

u/southern_discomfort May 30 '19

RHEL 8 was officially released a few weeks ago. CentOS 8 will not be far behind.

1

u/PooPooDooDoo May 30 '19

It’s fine, we will all have 14 days (during the holidays) to update our code base. Except I am using libraries that are in 2, so I’ll have to wait until they update and then update my code base. So like one day.

-4

u/rasherdk May 30 '19

Python 2.7 will not get security updates after Jan 1st, 2020.

Depends.

1

u/jackmaney May 30 '19

It really doesn't.

4

u/rasherdk May 30 '19 edited May 30 '19

What, yes it does. It (likely) won't get any from PSF. That's not the same as no security updates period.

Edit: Downvoting doesn't make you right. Spreading FUD is not the way to go.

7

u/james_pic May 30 '19

This is true. The version in RedHat will get updates until 2024, and the version in Ubuntu 18.04 will get updates until April 2023.

8

u/w2qw May 30 '19

Shipping or using it as the default? It makes sense that they would still ship it while it's supported.

9

u/Jump3r3 May 30 '19

Using as default, which python yields path to python 2 binary on most distros. That being said, after 1/1/20 this will slowly change for better

→ More replies (4)

2

u/ALonelyPlatypus Jun 28 '19

8 years of python experience. a year ago I did the jump to python3. Still struggling with print parens.

3

u/kastoro May 30 '19

Fine, I will do it!

5

u/greeblefritz May 30 '19

The switch isn't as bad as you are probably thinking.

8

u/jjdmol May 30 '19 edited May 30 '19

It isn't bad, but the required effort does scale with the size of your code base. 2to3 only covers some basics, many behavioural differences are more subtle. And python being interpreted you'll discover errors at run time, so will need good test coverage or do a lot of testing.

2

u/PeridexisErrant May 30 '19

Try the pyupgrade and future libraries - they do a lot more than 2to3 :-)

7

u/james_pic May 30 '19

Futurize did more harm than good when we tried it. It tries to paper over the genuinely different string semantics, and left us with something broken that we understood even less than what we started with.

Modernize is more conservative, and in our experience, gives a better starting point. If you've got a big codebase, you've still got an uphill battle ahead of you.

Also, use mypy type hints. In general, I hate them, but they're really helpful for clarifying type usage in legacy codebases.

1

u/PeridexisErrant May 30 '19

Hmm, thanks for the tip! I've use futurize --stage1 a fair bit but never really liked the second stage... though just getting syntax-compatible with Python 3 allows many more tools to work.

I'll try modernize :-)

1

u/kastoro May 30 '19

Thanks, that is encouraging. Is what I thought, I just never found the time to do it, you know, always behind schedule

5

u/stefantalpalaru May 30 '19

What is dead may never die, but rises again harder and stronger: https://github.com/naftaliharris/tauthon/

10

u/NoahTheDuke May 30 '19

Ew. Why would someone spend that much effort on a broken version of Python?

→ More replies (5)

2

u/sphildreth May 30 '19

I was surprised to learn that CentOS 7 still uses Python 2.7 as its default.

2

u/omento SysAdmin Film/VFX - 3.7 May 30 '19

RHEL 7 came out in 2014 and had its version freeze in 2013, when Python 3.3 was a thing. This is well before Python 3 support really took off. The point of RHEL is to provide 10 years of rock solid platform support, so critical system level packages (like GLIBC, gcc, and python) do NOT change versions or break ABI at all in the products lifespan. Some of the OS level tools, like yum, are written primarily in Python so making an upgrade would break that.

RHEL 8 provides a new solution for this by providing a ‘hidden’ python version for dependent OS tools, while allowing the user to install the python version of their choice from the appstream modules. Currently 2.7 and 3.6 are available for use. Red Hat also rewrote a lot of tooling to not use python, or reduce the dependency on it to further help with this.

1

u/[deleted] May 30 '19
 ~ $ sudo apt purge python2.7-minimal --auto-remove 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  libpython2.7-minimal* nodejs* python-minimal* python2-minimal*
  python2.7-minimal*
0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
After this operation, 78.8 MB disk space will be freed.
Do you want to continue? [Y/n] 

1

u/yeluapyeroc May 30 '19

My number one velocity killer right now, but I'm glad its finally happening

1

u/cr4d May 30 '19

I'm looking forward to dropping 2 support from my public libraries for sure.

1

u/[deleted] May 30 '19

Can’t you just transfer you project to python 3.7

1

u/[deleted] May 31 '19

It was a painful transition but man was it successful from my eyes. Good work nerds!!

1

u/IchBinDerFlo Jun 02 '19

Cause I already use Py3 it doesn't really matter for me

1

u/[deleted] May 30 '19

I don't understand why it takes so long. For ages python 2 comes with tools that help you to migrate to python 3 smoothly. Python code isn't even that hard to port in most cases. It's it because of C libraries?

6

u/alcalde May 30 '19

It's because of users.

In the Delphi langauge's move to Unicode they introduced "ANSI strings" (8bit non-Unicode strings) as a tool to allow users to compile their old code in the new version and gradually port over to Unicode.

What happened? Many users continued to write all of their new code using ANSI Strings and kept right on going like nothing ever happened. Then when there was talk years later of rewriting the compiler and consequently dropping ANSI strings, these users screamed "Wait! We haven't had any time to convert!"

It got so bad these people managed to get ANSI strings added to the new Delphi Android and iOS compilers, which had never had non-Unicode strings in the first place! :-(

The same kind of thing happened to Python 2. When I had asked the then-maintainer of Pyjamas (??? - one of the Python to Javascript transpilers anyway) about porting to Python 3, he answered "Python 2 is going to be supported forever, so why bother?"

We've got a user here who continues to insist that the PSF will still move the support deadline for Python 2; maybe they're the same person.

0

u/[deleted] May 30 '19

[deleted]

4

u/fireflash38 May 30 '19 edited May 30 '19

That doesn't even get into supporting varied OSes & distros, even old ones (we get stuff for: HPUX, AIX, Solaris, SunOS, etc). Shit, we still get some support requests for WS2008. We have to have a 'quarantine' lab for a lot of the OSes we support because corp doesn't want them on their network (understandably).

Most of the time when I see people lambasting others using python2 they are in a small company or startup, or a company that is heavily web-focused. You can usually tell by how much they talk about unicode (instead of bytestring) :) If you're at all doing low-level system stuff, the conversion can be quite painful as you've said.

1

u/mobilereadingthrwawy 2.7.16 & 3.7.2 May 30 '19

2020-01-01*

1

u/Sin-Silver May 30 '19

So I’ve been studying Python for two weeks now following ‘Learn Python the hard way’ which recommends python 2.7 over 3. What does this mean for me?

3

u/Mr_Again May 31 '19

The author has, or had, a weird grudge against py3. Just ignore it and learn Python 3. It's almost 100% the same when you're starting out, except for print, xrange, and anything involving unicode.

1

u/Sin-Silver Jun 01 '19

Would it be worth learning python 3 later then if there little or no difference?

I don’t want to get stuck on a problem it’s trying to each because of a difference between 2.7 and 3 that’s not transparent.

1

u/Mr_Again Jun 01 '19

Honestly no, if it's an issue just learn the python 3 way of doing things, you'll probably never use python 2, it's dead now.

1

u/Sin-Silver Jun 01 '19

So how hard would it to take what I’ve learnt from Python 2.7 and transfer it to 3?

I’m looking at changing courses, but I’ve sunk alot of time into it, and don’t want to unless necessary.

1

u/Mr_Again Jun 01 '19

Like I said it's almost exactly the same, you won't notice the difference

4

u/mountainunicycler May 30 '19

You should switch to 3, but it won’t make a ton of difference at your point so you might be able to keep using the same tutorials with the exception of the print statement.

1

u/Sin-Silver Jun 01 '19

Would it be worth learning python 3 later then if there little or no difference?

I don’t want to get stuck on a problem it’s trying to each because of a difference between 2.7 and 3 that’s not transparent.

2

u/mountainunicycler Jun 01 '19

Many of the changes between python 2 and python 3 make it easier to learn; python3 is more consistent and easier to understand—and at this point there’s no benefit to learning the quirks of python 2 because they’ve been fixed.

I’d definitely recommend switching to a python 3 course.

1

u/Sin-Silver Jun 01 '19

I’ll have a hunt around. any recommendations on books?

2

u/mountainunicycler Jun 01 '19

I’m not sure about books; I just learned by making things and looking up how to do it when I got stuck (so basically searching stack overflow for each line when I was starting).

In my opinion you learn a lot faster when you have a goal in mind if something to build.

1

u/alcalde May 30 '19 edited May 30 '19

Where's /u/nieuweyork? They were insisting that the PSF will definitely extend the support deadline for Python 2 again or else it would be catastrophic for Python... "Actually stopping security patches for 2.7 runs the risk that someone starts funneling funds to a new organisation that will keep patching a 2.7 compatible version. This would be...not good for the Python Foundation."

https://old.reddit.com/r/Python/comments/bq4v99/amber_brown_batteries_included_but_theyre_leaking/eo27h5b/?context=10

-1

u/nieuweyork since 2007 May 30 '19

Yeah I'll believe it when the deadline hits. This has been "definitely going to happen" more than once in the past.

5

u/alcalde May 30 '19

It's almost June 1 and Guido himself is still saying it's going to happen. Do you think it's going to change December 31, or....?

This has been "definitely going to happen" more than once in the past.

But the conditions of the past are not the current conditions. If a doctor once says he believes you're going to die and you survive, you're not rendered functionally immortal as a result.

As I've told you before, every major library from Pandas to Django is running on Python 3 now and many, including major web and scientific computing stack libraries, have already ended support for Python 2. That was certainly not the case when the deadline was extended in the past. In short, there's no need to extend the deadline again. What conditions do you see continuing to exist that would render a last-minute reprieve necessary?

0

u/nieuweyork since 2007 May 30 '19

Well, significant usage of 2.7 continuing through to the present.

4

u/flying-sheep May 31 '19

Significant, but not enough. Companies that didn’t switch now will never switch if the deadline would be pushed out for them. They’re the kind of companies that only starts thinking about buying fire extinguishers when 33% of the premises have burnt down and the fire has started to lick at the CEO’s rolls royce.

3

u/flying-sheep May 30 '19

Everyone important has said that this date is final.

0

u/fedeb95 May 30 '19

Finally

0

u/Skyfoot May 30 '19

RemindMe! 1st Dec 2019 "Hand in your notice"

0

u/RemindMeBot May 30 '19

I will be messaging you on 2019-12-01 17:23:27 UTC to remind you of this link.

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


FAQsCustomYour RemindersFeedbackCodeBrowser Extensions

0

u/bgosh May 30 '19

I can't wait.

Then we might actually have a stable python version...

0

u/[deleted] May 30 '19

Learner here, does this mean I should uninstall any/all version of python2 on my laptop along with libraries??? (I'm already using python 3.6 for all my projects, just wondering if I should keep python2)

13

u/hachihoshino May 30 '19

If it's a version of python 2 you installed yourself, then yeah, sure. However, if it's a version of python 2 that came installed with the system, it's best not to touch it - your OS is probably using that for some internal stuff and you don't know what you might break if you try to remove it.

4

u/liquidpele May 30 '19

But DO install python3 alongside the system python and use 3 for everything!

0

u/JezusTheCarpenter May 30 '19

Any specific quide how to deal with the transition of the the Python C API as apparently this will be different in Python3? Mayb it will be a good opportunity to switch to PyBind11.

-26

u/[deleted] May 30 '19

You can't really End of Life open source software like python. GPL compatible means irrevocability of copy-lefts. Business and end users who still use python 2 will support it without resources from the PSF. Large projects that never left python2 will switch to that repository/code base.

An entire desktop environment was created around gnome 2's deprecation. Python 2.7 is going to live on forever, a monument to poor project management decisions regarding backwards compatibility.

23

u/aEverr May 30 '19

EOL in this case just means loss of support from the official (?), so anyone can update it, but don't rely on it

2

u/port53 relative noob May 30 '19

Red Hat will support py2 for a few more years. With those patches then going to centos, that's all people will need to keep using it.

1

u/kyrsjo May 30 '19

That's great for the Linux users who are already on RHEL, or can switch distro easily...

→ More replies (7)

1

u/cediddi SyntaxError: not a chance May 30 '19

Some corporation may provide paid support for a custom python distro (Anaconda?) and that's okay. Psf may as well, but not the official repo. That's it. I can still install python 1.6 and it works and until some years ago, some companies supported their embedded py 1.6 setups.

4

u/[deleted] May 30 '19

Python 2.7 is going to live on forever, a monument to poor project management decisions regarding backwards compatibility.

Probably true, but probably uninteresting to most of us, since we won't see them.

1

u/[deleted] May 31 '19

call me when /usr/bin/python -v doesn't return 2.7.x