Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78862
| Date | 2014-10-08 16:35 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: operator module functions |
| References | (5 earlier) <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14699.1412811314.18130.python-list@python.org> (permalink) |
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
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