[Python-ideas] Fwd: Null coalescing operator
Random832
random832 at fastmail.com
Tue Sep 13 10:14:08 EDT 2016
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.
More information about the Python-ideas
mailing list