this post was submitted on 26 Jul 2023
12 points (100.0% liked)

Python

7306 readers
2 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] ExperimentalGuy@programming.dev 0 points 2 years ago (12 children)

This is pretty cool, but I have no idea what the significance is.

[–] rglullis@communick.news 5 points 2 years ago (3 children)

The key part is this:

it turns out protocols really are just a formalization of Python's duck typing.

Meaning, this is just a way to say that if you are defining some system that needs to conform with some interface, you can have type checked even if your have different objects from different classes. No need for TypeVar or define a crazy hierarchy: as long as the types implements the methods defined by the Protocol, the type checker will be happy.

[–] bleistift2@feddit.de 1 points 2 years ago* (last edited 2 years ago) (2 children)

It’s amazing how often people celebrate some new feature in a language and I’m like: TypeScript has been doing this for years now.

[Edit: This is also how interfaces work in Go, and it’s just the old advice “Code against interfaces, not classes.”]

[–] tenextrathrills@burggit.moe 4 points 2 years ago

It's almost like python and typescript are used by different people for different purposes and have therefor developed differently, but some features end up being an overall good idea which enrich their respective ecosystems.

You sound like an absolute tool.

[Edit: Who f*cking cares]

load more comments (1 replies)
load more comments (1 replies)
load more comments (9 replies)