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


Groups > comp.lang.python > #78862

Re: operator module functions

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; '*not*': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'indeed,': 0.09; 'message- id:@stoneleaf.us': 0.09; 'subject:module': 0.09; 'unittest': 0.09; '~ethan~': 0.09; "','": 0.16; '(given': 0.16; 'argument)': 0.16; 'delimit': 0.16; 'lambda': 0.16; 'merely': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'stack': 0.19; '(the': 0.22; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'adds': 0.24; "aren't": 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; "i'm": 0.30; '>>>>': 0.31; 'convenience': 0.31; 'layer': 0.31; 'call.': 0.33; 'but': 0.35; 'opposed': 0.36; 'thanks': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'received:173': 0.61; 'simply': 0.61; 'back': 0.62; 'more': 0.64; 'situation': 0.65; 'therefore': 0.72; 'comment.': 0.84; 'confusing': 0.84; 'ethan': 0.84; 'furman': 0.84; 'mind:': 0.84; 'springs': 0.84
Date Wed, 08 Oct 2014 16:35:11 -0700
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: operator module functions
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> <543592AE.80807@stoneleaf.us> <1412797764.3704154.176743089.32D63D13@webmail.messagingengine.com> <54359623.8060307@stoneleaf.us> <1412803417.3733140.176776081.0B98584A@webmail.messagingengine.com> <5435B14C.9020907@stoneleaf.us> <m14erh$ra3$1@ger.gmane.org>
In-Reply-To <m14erh$ra3$1@ger.gmane.org>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
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.14699.1412811314.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1412811314 news.xs4all.nl 2909 [2001:888:2000:d::a6]:56915
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78862

Show key headers only | View raw


On 10/08/2014 03:46 PM, Terry Reedy wrote:
> On 10/8/2014 5:49 PM, Ethan Furman wrote:
>> [redirecting back to the list]
>
>>>>> I'm not sure what situation you would have to type them (as opposed to
>>>>> simply a + b) that the operator module would help with.
>>>>
>>>> unittest springs to mind:
>>>>
>>>>     self.assertRaises(TypeError, op.add, obj1, obj2)
>>>
>>> Er, my point is, that is not a situation where you would be able to use
>>> obj1.__add__ - you'd have to use the operator module *anyway*, and
>>> therefore aren't using it just to get the convenience of a non-dunder
>>> name.
>>
>>   self.assertRaises(TypeError, lambda x, y: x+y, obj1, obj2)
>
> That works, but is a bit harder to type (given the import), more confusing to read (the extra ',' that does *not*
> delimit an argument) and adds an extra layer to the call stack with each call.  The extra layer *could* make a
> difference in recursion.

Indeed, thanks for the corrections.  I was merely replying to the "have to use the operator module anyway" comment.

--
~Ethan~

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