Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78851

Re: operator module functions

Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'syntax': 0.04; 'correspond': 0.09; 'function,': 0.09; 'obsolete': 0.09; 'subject:module': 0.09; 'trailing': 0.09; 'underscore': 0.09; 'wrong,': 0.09; 'python': 0.11; 'mostly': 0.14; '"official"': 0.16; 'methods;': 0.16; 'naming': 0.16; 'operators.': 0.16; 'reedy': 0.16; 'symbols': 0.16; 'variants': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'creating': 0.23; 'module,': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; "d'aprano": 0.31; 'names.': 0.31; 'operators': 0.31; 'steven': 0.31; 'class': 0.32; 'table': 0.34; '"the': 0.34; "i'd": 0.34; 'something': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'curious': 0.36; 'functions.': 0.36; 'module.': 0.36; 'shows': 0.36; 'should': 0.36; 'two': 0.37; 'implement': 0.38; 'e.g.': 0.38; 'mapping': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'according': 0.40; 'how': 0.40; 'remove': 0.60; 'eventually': 0.60; 'special': 0.74; 'duplication': 0.84; 'etc,': 0.84; 'gelonida': 0.84; 'overloading': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=vYhYe4DJ4Ic0ex2kIIch2Ovfv4FiulM5ayLn7iNfy+I=; b=menlVvhs/e6C9bcgUUcP+esOsynP0mClQpk+zTe4G7FdkSBPeDIU5ivKtVQtZQ2scs NRdACYDvXb8PfpToXiDZHazB1r8Q3MWkzNHwV+l7L71byzhD87bHfbdqGxFNbjZvm30v rnaIVWr5aVetykRANImcFJo1tnjJGRU8aa+kG9xGjLoCTpDj6G86ziQqg3BuNCdQrOB1 +qwyWoPGhYzGcEByEIRdlP43rEiXkLp8kZMRuN6iFRfjV7jAS5jZ/g/XxR2gpEM7iym6 04cn9VGBS11BZvuvHK6g1/t95Lhj+gJkflVTtZCJqVdbA4KRDCN+GWnEcfekeF2xAwsN GQog==
X-Received by 10.66.222.74 with SMTP id qk10mr13879517pac.70.1412803439254; Wed, 08 Oct 2014 14:23:59 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <m148u6$iu9$1@ger.gmane.org>
References <54349662$0$12987$c3e8da3$5496439d@news.astraweb.com> <facda5ec-ecd9-43d0-99b3-b98f945a9a2d@googlegroups.com> <543518a5$0$12989$c3e8da3$5496439d@news.astraweb.com> <m1426b$kgq$1@ger.gmane.org> <m148u6$iu9$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 8 Oct 2014 15:23:18 -0600
Subject Re: operator module functions
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14690.1412803455.18130.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1412803456 news.xs4all.nl 2926 [2001:888:2000:d::a6]:38980
X-Complaints-To abuse@xs4all.nl
Path csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:78851

Show key headers only | View raw


On Wed, Oct 8, 2014 at 3:05 PM, Gelonida N <gelonida@gmail.com> wrote:
> On 10/8/2014 9:09 PM, Terry Reedy wrote:
>>
>> On 10/8/2014 6:57 AM, Steven D'Aprano wrote:
>>
>>> According to the documentation, operator.__add__ is the "official"
>>> function,
>>> and operator.add is just there for convenience.
>>
>>
>> You are paraphrasing "The function names are those used for special
>> class methods; variants without leading and trailing __ are also
>> provided for convenience."  But then there is the following:
>>
>> 10.3.1. Mapping Operators to Functions
>>
>> This table shows how abstract operations correspond to operator symbols
>> in the Python syntax and the functions in the operator module.
>> Operation     Syntax     Function
>> Addition     a + b     add(a, b)
>>
>> etc, using the 'convenient' names. I would like to deprecate and
>> eventually remove the dunder names.  To me, the duplication is not
>> 'convenient'.
>>
>
>
> I'd be curious about a proposal to obsolete the double underscore functions
> and just keep operator.add or to just keep the operator +
>
> For me they seem rather distinct, though they are interchangable in certain
> situations.
>
> Perhaps I got something wrong, but all dunder functions are 'magic'
> functions. Many of them mostly should ne used when when overloading
> behaviour or when creating a class which should implement operators.

This isn't about the dunder *method* names. It's about the naming of
the functions in the operator module, e.g. having both operator.add
and operator.__add__ that are two names for the same function.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

operator module functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-08 12:41 +1100
  Re: operator module functions Terry Reedy <tjreedy@udel.edu> - 2014-10-08 02:28 -0400
  Re: operator module functions marco.nawijn@colosso.nl - 2014-10-08 01:46 -0700
    Re: operator module functions Chris Angelico <rosuav@gmail.com> - 2014-10-08 20:32 +1100
      Re: operator module functions Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-10-09 10:37 +1300
        Re: operator module functions Chris Angelico <rosuav@gmail.com> - 2014-10-09 09:30 +1100
        Re: operator module functions Chris Kaynor <ckaynor@zindagigames.com> - 2014-10-08 15:40 -0700
    Re: operator module functions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-08 21:57 +1100
      Re: operator module functions Terry Reedy <tjreedy@udel.edu> - 2014-10-08 15:09 -0400
      Re: operator module functions Ethan Furman <ethan@stoneleaf.us> - 2014-10-08 12:38 -0700
      Re: operator module functions random832@fastmail.us - 2014-10-08 15:49 -0400
      Re: operator module functions Gelonida N <gelonida@gmail.com> - 2014-10-08 23:05 +0200
      Re: operator module functions Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-08 15:23 -0600
      Re: operator module functions Ethan Furman <ethan@stoneleaf.us> - 2014-10-08 14:49 -0700
      Re: operator module functions Chris Kaynor <ckaynor@zindagigames.com> - 2014-10-08 14:21 -0700
      Re: operator module functions Ben Finney <ben+python@benfinney.id.au> - 2014-10-09 08:57 +1100
      Re: operator module functions Terry Reedy <tjreedy@udel.edu> - 2014-10-08 18:46 -0400
      Re: operator module functions Ethan Furman <ethan@stoneleaf.us> - 2014-10-08 16:35 -0700
      Re: operator module functions Ned Batchelder <ned@nedbatchelder.com> - 2014-10-08 21:41 -0400

csiph-web