this post was submitted on 15 Sep 2023
1 points (100.0% liked)

Python

6356 readers
1 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 1 year ago
MODERATORS
 

This is like Interface in Go (or Java, i don't speak Java but the article say so).

top 2 comments
sorted by: hot top controversial new old
[โ€“] NostraDavid@programming.dev 0 points 1 year ago (1 children)

OK, but why would I use this over ABCs? (Abstract Base Class). Or is it just different?

[โ€“] bamboo@lemm.ee 1 points 1 year ago

Protocols are static duck typing. An object is a valid instance of protocol if it implements all the methods defined in the protocol, even if it doesn't declare it as implementing it. That last bit is important and the most distinguishing factor compared to an ABC.