Documentaion of dunder methods

Steven D'Aprano steve at pearwood.info
Mon May 25 23:17:59 EDT 2015


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.


-- 
Steven




More information about the Python-list mailing list