[Python-ideas] Deprecate dunder functions from operator module

Steven D'Aprano steve at pearwood.info
Tue Nov 4 04:57:04 CET 2014


On Sat, Nov 01, 2014 at 01:02:19PM -0700, Ethan Furman wrote:
> On 10/29/2014 06:38 PM, Ethan Furman wrote:
> >On 10/29/2014 05:53 PM, Steven D'Aprano wrote:
> >>
> >>I propose a few things:
> >>
> >>* institute a policy that, in the event of a new function being added
> >>   to the operator module, only the dunderless version will be added;
> >>
> >>* change the documentation to make it clear that the dunderless
> >>   versions should be used, rather than merely being "convenience"
> >>   functions;
> >>
> >>* add a prominent note that the dunder versions exist for backwards
> >>   compatibility only and should not be used in new code.
> >
> >+1
> 
> Actually, make that -1.
> 
> I'm just crafting some tests to explore how NotImplemented impacts various 
> classes, and the dunder versions make the whole thing much nicer.

I'm surprised. I can't imagine dunder names making anything look 
nicer. It sounds like you are writing "operator.__add__" instead 
of "operator.add", which doesn't look nicer to me.

Can you show me your code?

Note that the dunder versions won't be going away soon, if at all, so 
if your code is relying on them, they will still be there. They just 
won't be prominently advertised.



-- 
Steven


More information about the Python-ideas mailing list