[Python-Dev] Updated PEP 362 (Function Signature Object)

Larry Hastings larry at hastings.org
Wed Jun 6 18:36:15 CEST 2012


On 06/06/2012 09:05 AM, Larry Hastings wrote:
>> Is there a use-case for is_implemented?
>
> Yes, see issue 14626.

I should add, there are already some places in the standard library 
where is_implemented would be relevant.  The "mode" argument to os.mkdir 
comes immediately to mind; on Windows it is accepted but ignored.  A 
counter-example would be os.symlink, which takes an extra parameter on 
Windows that's  *not even accepted* on other platforms.

I am utterly convinced that, when faced with these sorts of 
platform-specific API differences, the first step towards sanity is to 
have the API accept a consistent signature everywhere.  What you do 
after that is up for debate--in most cases where the parameter causes a 
significant semantic change, I think specifying it with a non-default 
value should throw a NotImplementedError.  (With the specific case of 
os.mkdir on Windows, I can agree with silently ignoring the mode; it's 
not like the hapless Windows programmer could react and take a useful 
alternative approach.)

Parameter objects exposing is_implemented allows LBYL in these 
situations, rather than having to react to NotImplementedError.


//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120606/daeb7175/attachment.html>


More information about the Python-Dev mailing list