[Python-Dev] an alternative to embedding policy in PEP 418 (was: PEP 418: Add monotonic clock)

Stephen J. Turnbull stephen at xemacs.org
Fri Apr 6 04:57:20 CEST 2012

On Fri, Apr 6, 2012 at 12:22 AM, Oleg Broytman <phd at phdru.name> wrote:
> On Thu, Apr 05, 2012 at 11:45:06PM +0900, Stephen J. Turnbull wrote:
>> On Thu, Apr 5, 2012 at 10:34 PM, Oleg Broytman <phd at phdru.name> wrote:
>> >   Why doesn't open() return None for a non-existing file? or
>> > socket.gethostbyname() for a non-existing name?
>> That's not an answer to my question, because those calls have very
>> important use cases

Note, implicit existential quantifier.

>   Counterexamples

Not an argument against an existential quantifier.

> But Python doesn't allow [use of conditional constructs when opening a series of files, one must trap exceptions].

True.  Python needs to make a choice, and the existence of important
cases where the user knows that the object (file) exists makes it
plausible that the user would prefer an Exception.  Also, open() is
intended to be a fairly thin wrapper over the OS facility, and often
the OS terms a missing file an "error".

I might have chosen to implement a 'None' return if I had designed
open(), but I can't get too upset about raising an Exception as it
actually does.

What I want to know is why you're willing to assert that absence of a
clock of a particular configuration is an Exception, when that absence
clearly documented to be a common case?  I don't find your analogies
to be plausible.  They seem to come down to "sometimes in Python we've
made choices that impose extra work on some use cases, so we should
impose extra work on this use case too."  But that surely isn't what
you mean.

More information about the Python-Dev mailing list