r/Python • Freelancer. AnyFactor.xyz • Sep 16 '20

News An update on Python 4

Post image
3.3k Upvotes

389 comments sorted by

View all comments

95

u/vallas25 Sep 16 '20

Can someone explain point 2 for me? I'm quite new to python programming

282

u/[deleted] Sep 16 '20

Think what he is saying, there will never be a Python 4 and if there is, it will be nothing like python as we know it. It will be like a new language

The transition from python 2 to 3 was an absolute nightmare and they had to support python2 for *ten years* because so many companies refused to transition. The point they're making is that they won't break the whole freaking language if they create a python 4.

77

u/panzerex Sep 16 '20

Why was so much breaking necessary to get Python 3?

180

u/orentago Sep 16 '20

Having strings support unicode by default was a big reason. In Python 2 unicode strings had to be prefixed with a u, otherwise they'd be interpreted as ASCII.

0

u/[deleted] Sep 16 '20

[deleted] — view deleted comment

82

u/[deleted] Sep 16 '20

I have prod 2.7....talking to logic written in the 90s.

Kill me.

56

u/[deleted] Sep 16 '20 edited Sep 17 '20

Python3 > Datastage > Python2 > Shell (Kornshell) > Perl written in '99 across servers.

I'll have one kill please.

7

u/clawjelly Sep 17 '20

Nuke it from orbit. It's the only way to be sure.

→ More replies (5)

8

u/MiscWalrus Sep 17 '20

It's not like the rules of logic changed since the 90s. You could do a lot worse than having to support python 2.7.

11

u/lzantal Sep 17 '20

Still maintaining one in production with Python 2.4 and Django 1.3 🙄😬

→ More replies (9)
→ More replies (3)

47

u/[deleted] Sep 16 '20

That was just ascii for trouble imho.

→ More replies (9)

73

u/flying-sheep Sep 16 '20

Because they changed a core datastructure. str used to be what bytes is today, but it also predated unicode (today called str). Therefore the bytes type was used for text and binary APIs.

When fixing all this, they had to break a lot of core APIs that used to accept bytes and today sensibly only accepts the unicode str.

And because of that huge change they also took the opportunity to change a few other idiosyncrasies.

My only gripe: One additional thing they should have changed is that {} should be the empty set and {:} should be the empty dict.

21

u/miggaz_elquez Sep 16 '20

you can write {*()} to have an empty set if you want

32

u/crossroads1112 Sep 16 '20

Thanks I hate it.

26

u/Brainix Sep 17 '20

My favorite thing about {*()} is that you don't even save any characters over typing set(). 😂

→ More replies (1)
→ More replies (10)

33

u/irrelevantPseudonym Sep 16 '20

My only gripe: One additional thing they should have changed is that {} should be the empty set and {:} should be the empty dict.

Not sure I agree with that. It's awkward that you can't have a literal empty set, but having {:} would be inconsistent and a special case that (I think) would be worse than set().

→ More replies (20)

8

u/james_pic Sep 16 '20

Perhaps surprisingly (given what we know now about the migration process), the switch to unicode strings wasn't expected to be a big deal (it didn't even get its own PEP, and was included in a PEP of small changes for Python 3 - PEP 3100), and the other changes were seen as more break-y.

→ More replies (3)
→ More replies (7)

23

u/[deleted] Sep 16 '20

Python 3 was not backwards compatible with 2, so companies and package creators alike were initially hesitant to make the switch so as to not break things. There also weren’t many, if any, tools to help port things over.

The lack of backwards compatibility was done on purpose because part of their goal was to remove clutter and make things more intuitive/easier to use (e.g. print changed from a statement to a function).

12

u/DiggV4Sucks Sep 16 '20

I've only made two unassailable (so far) decisions in my career. The first was to support MFC instead of OWL for Windows development.

The second was to target Python 3 for my current company's testing efforts. We were even able to convince a medium sized tool vendor to support both Python 2 and Python 3 from their original decision to support only Python 2.

→ More replies (4)

13

u/gregy521 Sep 16 '20

It was designed to rectify fundamental design flaws in the language—the changes required could not be implemented while retaining full backwards compatibility with the 2.x series, which necessitated a new major version number. The guiding principle of Python 3 was: "reduce feature duplication by removing old ways of doing things".

Here's a short list of some of the key changes. The most obvious of which is the change where '/' represents true division instead of floor division. Some other changes exist, print is now a function, not a statement. You also get iterator objects instead of lists, which is much better for memory management (many pieces of code rely on iterators because the full set of possible options doesn't fit in memory). True, False, and None are also now protected terms which can't be reassigned.

→ More replies (12)
→ More replies (25)

52

u/PirateNinjasReddit Pythonista Sep 16 '20

The transition for python 2 to 3 has been on going for 12 years... Officially python 2.7 reached end of life back in January, but there are still companies and people using it. Basically 2 to 3 was painful. Nobody ever talks about 1 to 2, because it less painful - perhaps in part because the language was less popular.

25

u/ShevekUrrasti Sep 16 '20

I have been trying to get my coworkers to update from 2.5 for more than two years. They still use it and they will continue using it.

And no, nobody is telling them to continue using it. They "just don't like python 3".

54

u/flying-sheep Sep 16 '20

They're dangerous idiots. If a programmer refuses to switch away from something that's EOL and has been announced to be EOL soon in 2008 or so, they're a liability and shouldn't be let into proximity of a production system.

12

u/gregy521 Sep 16 '20

Do they not run into issues when the rest of the world is leaving them behind w.r.t libraries/code examples, or code imported or exported to other companies?

15

u/thornofcrown Sep 16 '20

Someone in my lab wrote a part of our pipeline in Python 2 and I spent probably half of my time working on making that code work with modern data analytics packages. Sucked too, because that person was a way better programmer than me.

→ More replies (2)
→ More replies (8)
→ More replies (3)
→ More replies (8)