Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-actionable information about protocols #23

Open
chillenzer opened this issue Jun 2, 2023 · 2 comments
Open

Non-actionable information about protocols #23

chillenzer opened this issue Jun 2, 2023 · 2 comments

Comments

@chillenzer
Copy link

chillenzer commented Jun 2, 2023

The information in "Duck Typing"'s section "Protocols" doesn't really sound actionable to me. What am I supposed to learn from this? And how can I apply this afterwards? As far as I know, Python doesn't have anything to enforce or abide by protocols explicitly (except for static typecheckers of course), so all you can do is know about it and do my very best to abide by protocols. Could we have this more actionable in some form?

Relatedly, using the Iterator protocol suggests that it could be about figuring out if something is iterable, which is surprisingly challenging/easy (depending on your allowed toolbox) to do reliably due to the different ways of being iterable.

@chillenzer
Copy link
Author

Okay. Should've read on where you are heading there. Abstract classes are an option but not a great one because you don't get the duck typing anymore.

@edbennett
Copy link
Member

I think the intended action here is to recognise the term "protocol" when the Python docs (or anyone else) use it, and be able to implement a protocol. There could potentially be another challenge around implementing another protocol if we can find a reasonable one—the problem starts to be come that understanding the problem to be solved and the protocol each become a non-trivial amount of work, even without starting the implementation.

I agree on ABCs not always being great, as duck typing is indeed nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants