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
Suggest change to glossary explanation: "Duck Typing" #47464
Comments
The official glossary entry here: I think it is should be changed to delete the use of hasattr and just The text would then read: The reason is that a hasattr test only tests for an attribute name. If
|
Georg, you may also want to amend this entry for ABCs. |
Paddy: IMO hasattr() is the "if it quacks like a duck" part of Benjamin: ABCs are not duck-typing since they involve isinstance() anyway. |
Hi Georg, On your comment about hasattr: I tried to get wider context on this by posting it originally to
|
While we are at it, should we keep this one as is? « Python3000 Not so mythical after all... missing the telepathic interface though. |
I actually would challenge the first sentence "A pythonic programming style which determines an object’s type by inspection of its method or attribute signature ". To me, and at least some usage on python-list, duck-typing means determining the interface (not type) by calling methods and catching exceptions if not present. This is the EAFP rather than inspection/LBYL style of duck typing. In 3.1: Python 3000 I suspect this was backported at the same time. |
Indeed. I would also remove "pythonic", because it will only confuse the |
Thanks, fixed the first sentence in r82760. |
Benjamin: Georg, you may also want to amend this entry for ABCs. Georg: ABCs are not duck-typing since they involve isinstance() anyway. Since ABCs provide virtual subclassing, using hasattr without requiring subclassing or registering, isn’t Benjamin right after all? |
Re-reading the glossary for both entries, they already link to each other, and the subtleties of ABCs can be learned later in their documentation. The glossary is good, sorry for the noise. |
To make one useful comment today: I noticed one missing :term: construct to link ABCs from duck typing. Attaching patch. |
Applied in r82790 by Georg, thanks! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: