Documentaion of dunder methods

Rustom Mody rustompmody at gmail.com
Mon May 25 23:30:07 EDT 2015


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 



More information about the Python-list mailing list