https://github.com/madi-s/protocols-vs-abc
https://github.com/madi-s/protocols-vs-abc
abc protocols python python-typing
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/madi-s/protocols-vs-abc
- Owner: Madi-S
- Created: 2024-08-28T11:36:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-28T12:43:26.000Z (about 1 year ago)
- Last Synced: 2025-04-04T01:18:42.813Z (6 months ago)
- Topics: abc, protocols, python, python-typing
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# protocls-vs-abc
A common question among the Python developers is whether to use protocols or abc module and when to put each of these two in a proper way.
Have a look at `abc_usecase.py` and `protocls_usecase.py` to grasp the difference and when it is suitable situtation for abc or protocols use.
Keep in mind, they serve the same purpose but are different in a way, so it is essential to understand when to use which tool.
Protocols are almost the same as abc, but allows you to use ducktyping instead of explicit typing.