The Real Python Podcast cover image

Exploring the New Features of Python 3.11

The Real Python Podcast

00:00

The New PEP 655 Self Type

Before self, we could try to kind of say, okay, I have a point class and this method returns point. But that wouldn't work because point doesn't define yet. So then there were things like you could add quotes around point and then the type checkers will be able to figure it out. But this wasn't quite enough either because if you would then start to do subclasses of your point, then the annotation that is returns a point is no longer true. There's a lot of kind of subtleties in how to actually annotate these kind of return values. And that's now whole kind of wrapped into this new self type that just handles everything. You can now

Transcript
Play full episode

The AI-powered Podcast Player

Save insights by tapping your headphones, chat with episodes, discover the best highlights - and more!
App store bannerPlay store banner
Get the app