top | item 41798017

(no title)

silvester23 | 1 year ago

What they mean is that in Java, for example, a method has to explicitly state which exceptions it might throw as part of its signature. Note that they said "throws", not "throw".

Python does not have that.

discuss

order

BerislavLopac|1 year ago

Ah, I understand now. Well, by default Python doesn't declare a return type either yet the tools are able to infer it in many cases; I see no reason why tools like mypy couldn't similarly infer the raised exception types as well.

Plus, the typing annotations could presumably be expanded to include some notification to declare raised exception types explicitly.