Documentaion of dunder methods

Mark Lawrence breamoreboy at yahoo.co.uk
Tue May 26 03:24:38 EDT 2015


On 26/05/2015 04:30, Rustom Mody wrote:
> On Tuesday, May 26, 2015 at 8:48:11 AM UTC+5:30, Steven D'Aprano wrote:
>> On Tue, 26 May 2015 12:17 pm, Steven D'Aprano wrote:
>>
>>> In other words, dunder methods are reserved for use by the core developers
>>> for the use of the Python interpreter.
>>
>> Er, that's easy to misinterpret. Let me try rewording:
>>
>> You should not invent new dunder methods.
>>
>> And if possible, you should not call such dunder methods directly. Instead,
>> use the official protocol (e.g. next(x), not x.__next__()) whenever
>> possible. The operator module contains many helpers for that.
>>
>> But of course you may *write* dunder methods.
>
> I guess you and I know what we want to convey and to proscribe.
> However the above doesn't pass muster as documentation
> The most glaring lack in the docs is some reification of the acceptable
> 'protocols'.
> Yeah people like to wax about duck-typing but that translates into semi-formal
> protocols and they are just not documented
>

All you need do is raise an issue on the bug tracker with an attached patch.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list