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

Stephen J. Turnbull stephen at xemacs.org
Thu Apr 5 16:45:06 CEST 2012


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 where the user knows the object exists (and in
fact in some cases open() will create it for him), so that failure to
exist is indeed a (user) error (such as a misspelling).  I find it
hard to imagine use cases where "file = open(thisfile) or
open(thatfile)" makes sense.  Not even for the case where thisfile ==
'script.pyc' and thatfile == 'script.py'.

The point of the proposed get_clock(), OTOH, is to ask if an object
with certain characteristics exists, and the fact that it returns the
clock rather than True if found is a matter of practical convenience.
Precisely because "clock = get_clock(best) or get_clock(better) or
get_clock(acceptable)" does make sense.


More information about the Python-Dev mailing list