News for hackers. Stuff that matters.
Re:Python 3.11: “Zero cost” exception handling by zohch on Wednesday October 06, 2021 @09:41AM (#28773061)
But that would not be for control flow.
Re:Python 3.11: “Zero cost” exception handling by foobarbecue on Wednesday October 06, 2021 @09:43AM (#28773075)
On a smaller scale, it is.
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.

Re:Python 3.11: “Zero cost” exception handling by zohch on Wednesday October 06, 2021 @10:13AM (#28773432)
Thanks for the clarification, I have actually seen this now that I think of it and this indeed is closer to control flow than error flow.
Re:Python 3.11: “Zero cost” exception handling by gpderetta on Wednesday October 06, 2021 @10:12AM (#28773419)
This is also known in Python as the "ask for forgiveness not permission" idiom.