Re:Python 3.11: “Zero cost” exception handling
by foobarbecue on Wednesday October 06, 2021 @09:43AM
(#28773075)
On a smaller scale, it is.
[ Parent
| on HN ]
Re:Python 3.11: “Zero cost” exception handling
by zohch on Wednesday October 06, 2021 @09:50AM
(#28773182)
To me sending wrong arguments is an error condition, not control flow, see this for more info: https://softwareengineering.stackexchange.com/questions/1892...
Re:Python 3.11: “Zero cost” exception handling
by ziml77 on Wednesday October 06, 2021 @09:59AM
(#28773282)
It's not about sending the wrong arguments. In Python a function may support a variety of types in a single argument. But instead of querying the type and switching based on that, you often want to try to call a method and if you get an exception (because that method does not exist), try to call a different method that gets you what you need.
The advantage to this over checking the type is that you are still use duck typing. If you check the type then you can only support a specific set of classes.