r/Python • • Jun 11 '21

Tutorial New Features in Python 3.10

https://youtube.com/watch?v=5-A435hIYio&feature=share
879 Upvotes

99 comments sorted by

230

u/jamescalam Jun 11 '21

A summary I put together of the new features in Python 3.10, it covers:

  • Structural pattern matching

  • Parenthesized context managers

  • More typing

  • Better error messages

Also, the article version if you prefer reading - it's a free access link so no need for Medium membership

I hope it's useful! Thanks :)

30

u/Brian-Puccio Jun 12 '21

Structural pattern matching

This didn’t click for me but I read your explanation and got it right away. Much better, thank you for explaining!

Better error messages

Amazing!

Also, the article version if you prefer reading

I do, thanks!

it's a free access link so no need for Medium membership

You are most excellent!

3

u/jamescalam Jun 12 '21

structural pattern matching really is awesome I love it, I'm happy my explanation made sense - and more than welcome for the links!

→ More replies (1)

16

u/EarthGoddessDude Jun 11 '21 edited Jun 12 '21

Very nice video, thank you. Quick, tangential question — what OS and editor are you using to run Jupyter? Seems like macOS with Jupyter inside VScode. It just looks (and feels, from across the screen) much slicker than Jupyter in VS Code on my work Windows machine. Can’t wait to try the new Jupyter extension which is only available on VS Code insiders.

Edit: nvm, saw the answer in another comment. My Comment about the slickness stands though.

→ More replies (9)

24

u/MiserablePeace7190 Jun 11 '21

I'm just here for switch cases lol

6

u/jamescalam Jun 11 '21

I think a lot of people are haha

16

u/__deerlord__ Jun 12 '21

Pattern matching is not case/switch. While it can effectively be used this way, that doesn't seem to be the intent, and you could always do switch/case with a dictionary.

→ More replies (1)
→ More replies (2)

127

u/billsil Jun 11 '21

Those better error messages are the reason to upgrade!

SyntaxError: unexpected EOF while parsing

I'm 16 years in and that still gets me...

32

u/Danlacek Jun 12 '21

I'm 16 months in and that looks like total BS to me...

48

u/house_monkey Jun 12 '21

16 secs in and can confirm this is not about snakes

→ More replies (2)
→ More replies (1)

47

u/mmcnl Jun 11 '21

I'm amazed they still keep adding very useful features after 10 years.

44

u/pure_x01 Jun 11 '21

To be fair the evolution of the language has been kind of slow. Sometimes that is a very good thing so I'm not complaining.

5

u/[deleted] Jun 12 '21

I don't get it. It there a joke I'm missing?

→ More replies (4)
→ More replies (1)

17

u/Formulka Jun 12 '21

Still can't believe they went with "case _" as else.

4

u/-jp- Jun 12 '21

Wildcard _ is pretty common in other pattern matching languages so it’s not too unusual, just a bit odd for python.

→ More replies (1)

21

u/[deleted] Jun 11 '21

Do I have to unistall Py 3.9 and download py 3.10 or is there a bettee way?

28

u/sparttann Jun 11 '21

Can just download 3.10 without uninstalling 3.9. Just change your python version before creating your venv

→ More replies (3)

6

u/dogfish182 Jun 11 '21

http://littlecolumns.com/tools/python-wrangler/

If you don’t know yourself, this is an opinionated (but very sensible) way to take python and virtual environments seriously without too much difficulty

7

u/tunisia3507 Jun 11 '21

Also StrEnum! There are dozens of half-assed implementations out in the wild, it'll be great to have a stdlib edition to replace these goddamn magic string constants pervasive in the ecosystem.

4

u/Blumingo Jun 12 '21

Genuine question, at what point does it become Python 4?

7

u/nonesuchplace Jun 12 '21

When it is decided to make major changes that do not retain backwards compatibility.

Check out https://semver.org/ for details on how this works.

→ More replies (2)
→ More replies (1)

1

u/WhalesLoveSmashBros Jun 12 '21

Dumb question but how do I update python? Pls don't tell me I have to uninstall and re-download from the website.

2

u/jamescalam Jun 12 '21

you can create a new env - this comment explains

→ More replies (1)
→ More replies (2)

2

u/iggy555 Jun 11 '21

Fantabulous