13 Sep
2016
13 Sep
'16
7:44 p.m.
On Tue, Sep 13, 2016, at 07:37, Nick Coghlan wrote:
P.S. There are also some use cases where Look-Before-You-Leap is inherently subject to race conditions,
Which use cases *aren't*?
and for those, exceptions are the only reliable signaling mechanism.
It's entirely possible to design a non-exception interface without race conditions. dict.get is *almost* a suitable example of such a method. Remember, at the C level in CPython, throwing an exception *is* returning a value [typically (PyObject*)NULL for interfaces that otherwise return an object], along with setting the error indicator. The only missing piece is an "error value" outside the set of valid values. Guido's argument here seems to be that exception-based EAFP is not pythonic.