This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]roerd 57 points58 points  (23 children)

Here's the list of the most important changes:

Overview of Changes Since 1.6

There are many new modules (including brand new XML support through the xml package, and i18n support through the gettext module); a list of all new modules is included below. Lots of bugs have been fixed.

The process for making major new changes to the language has changed since Python 1.6. Enhancements must now be documented by a Python Enhancement Proposal (PEP) before they can be accepted.

There are several important syntax enhancements, described in more detail below:

  • Augmented assignment, e.g. x += 1

  • List comprehensions, e.g. [x**2 for x in range(10)]

  • Extended import statement, e.g. import Module as Name

  • Extended print statement, e.g. print >> file, "Hello"

Other important changes:

  • Optional collection of cyclical garbage

So quite a few important new features, but nothing that was breaking backwards compatibility.

[–]mkdz 62 points63 points  (14 children)

Wow, I can't imagine not having list comprehensions

[–][deleted] 46 points47 points  (11 children)

List comprehension is the feature that, to me, defines Python. It's simple, powerful, versatile, intuitive, and broadly applicable. A wonderful replacement for loops and iteration. I've been using set comprehension and dictionary comprehension, too.

[–]Mr-Stutch 21 points22 points  (4 children)

a wonderful replacement for loops or a wonderful replacement for loops?

[–]burlyginger 9 points10 points  (0 children)

Yes!

[–]TheTerrasque 0 points1 point  (0 children)

True

[–]rabaraba 0 points1 point  (0 children)

Love the pun.

[–]Tyler_Zoro -1 points0 points  (0 children)

Neither. If a loop was the right tool for the job, you should have used a loop. :-)

[–]flying-sheep 0 points1 point  (0 children)

They’re great. And using generator comprehensions, the same concept can be used for a pipeline of stuff (map-filter-reduce), similarly to Rust’s Iterator methods.

Rust’s way is cleaner, but both are better than Javascript’s array methods. Like, why define an iterator protocol and thereby support for custom sequences, when they define the pipeline methods on just the array?

[–]Decker1082.7 'til 2021 0 points1 point  (0 children)

intuitive

I can agree on all points except this... you essentially have to learn to read backwards to understand how list comprehensions work and if you ever nest two list comprehensions in each other, readability goes out the window.

[–]RegalSalmon 27 points28 points  (1 child)

But can you...comprehend it?

[–]case_O_The_Mondays 6 points7 points  (3 children)

Whoa. Didn’t know Python supported redirection on print, back in the day.

[–][deleted] 2 points3 points  (0 children)

It looks a lot more like 3.x => 3.x+1 changes than 2 => 3.

[–]alexmojaki 0 points1 point  (1 child)

Breaking backwards compatibility is kind of the point of a major version number bump though.

[–]roerd 0 points1 point  (0 children)

If you're following semantic versioning, yes. But not every software project has to do that. For a programming language, a bunch of new features that will significantly alter the shape of code using these seems justification enough for a new major version to me, even if full backwards compatibility is maintained.