[Python-ideas] Dunder method to make object str-like

Ethan Furman ethan at stoneleaf.us
Mon Apr 11 17:19:39 EDT 2016


On 04/11/2016 02:09 PM, Nikolaus Rath wrote:
> On Apr 11 2016, Ethan Furman <ethan-gcWI5d7PMXnvaiG9KC9N7Q at public.gmane.org> wrote:
>> On 04/11/2016 07:43 AM, Nikolaus Rath wrote:
>>> On Apr 10 2016, Ethan Furman wrote:
>>
>>>> By having a well-defined protocol and helper function we not only make
>>>> our own lives easier but we also make the lives of third-party
>>>> libraries and experimenters easier.
>>>
>>> To me this sounds like catering to a hypothetical audience that may want
>>> to do hypothetical things. If you start with the above, and people
>>> complain that their favorite non-pathlib path library is not supported
>>> by the stdlib, you can still add a protocol. But if you add a protocol
>>> right away, you're stuck with the complexity for a very long time even
>>> if almost no one actually uses it.
>>
>> The part of "make our own lives easier" is not a hypothetical
>> audience.
>
> My assumption was that "own" refers to core developers here, while..

It does.

>> Making my own library (antipathy) work seamlessly with pathlib and
>> DirEntry is not hypothetical.
>
> ..here you seem to be wearing your third-party maintainer hat :-).

I was.  :)

> As far as I can see, implementing a protocol instead of adding a few
> isinstance checks is more likely to make the life of a CPython developer
> harder than easier.

I disagree.  And the protocol idea was not mine, so apparently other 
core-devs also disagree (or think it's worth it, regardless).  Even 
without the protocol I would think we'd still make a separate function 
to check the input.

--
~Ethan~


More information about the Python-ideas mailing list