Re: operator module functions

2014-10-08 Thread Ned Batchelder
On 10/8/14 5:49 PM, Ethan Furman wrote: [redirecting back to the list] On 10/08/2014 02:23 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:53, Ethan Furman wrote: On 10/08/2014 12:49 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: LOL, no kidd

Re: operator module functions

2014-10-08 Thread Ethan Furman
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

Re: operator module functions

2014-10-08 Thread Terry Reedy
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 poi

Re: operator module functions

2014-10-08 Thread Chris Kaynor
On Wed, Oct 8, 2014 at 3:30 PM, Chris Angelico wrote: > > > > > > That doesn't always seem to have been the case, however. > > In Python 2.7 and 3.3, I get > > > operator.add is operator.__add__ > > False > > Huh. So it is. > > rosuav@sikorsky:~$ python3 > Python 3.5.0a0 (default:301b9a58021

Re: operator module functions

2014-10-08 Thread Chris Angelico
On Thu, Oct 9, 2014 at 8:37 AM, Gregory Ewing wrote: > Chris Angelico wrote: > > operator.add is operator.__add__ >> >> True > > > That doesn't always seem to have been the case, however. > In Python 2.7 and 3.3, I get > operator.add is operator.__add__ > False Huh. So it is. rosuav@sik

Re: operator module functions

2014-10-08 Thread Ben Finney
random...@fastmail.us writes: > On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: > > The main reason I bother using the operator module is for the > > readability of not seeing the dunders, and the writability of not > > having to type them. > > I'm not sure what situation you would have to type

Re: operator module functions

2014-10-08 Thread Chris Kaynor
On Wed, Oct 8, 2014 at 2:05 PM, Gelonida N 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

Re: operator module functions

2014-10-08 Thread Ethan Furman
[redirecting back to the list] On 10/08/2014 02:23 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:53, Ethan Furman wrote: On 10/08/2014 12:49 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: LOL, no kidding! The main reason I bother using the

Re: operator module functions

2014-10-08 Thread Gregory Ewing
Chris Angelico wrote: operator.add is operator.__add__ True That doesn't always seem to have been the case, however. In Python 2.7 and 3.3, I get >>> operator.add is operator.__add__ False -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: operator module functions

2014-10-08 Thread Ian Kelly
On Wed, Oct 8, 2014 at 3:05 PM, Gelonida N 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 a

Re: operator module functions

2014-10-08 Thread Gelonida N
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;

Re: operator module functions

2014-10-08 Thread random832
On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: > LOL, no kidding! The main reason I bother using the operator module is > for the readability of not seeing the dunders, > and the writability of not having to type them. I'm not sure what situation you would have to type them (as opposed to

Re: operator module functions

2014-10-08 Thread Ethan Furman
On 10/08/2014 12: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 metho

Re: operator module functions

2014-10-08 Thread Terry Reedy
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 __

Re: operator module functions

2014-10-08 Thread Steven D'Aprano
marco.naw...@colosso.nl wrote: > For me it makes sense. operator.add should be used in a "global" context > (I don't know how to express it otherwise). So you provide it with the > two values that you want to add. The .__add__ variants are bound to a > particular instance and you provide it with a

Re: operator module functions

2014-10-08 Thread Chris Angelico
(You didn't include any context in your post. Please quote as much text as would be helpful; it's the easiest way to show what you're talking about.) On Wed, Oct 8, 2014 at 7:46 PM, wrote: > For me it makes sense. operator.add should be used in a "global" context > (I don't know how to express i

Re: operator module functions

2014-10-08 Thread marco . nawijn
For me it makes sense. operator.add should be used in a "global" context (I don't know how to express it otherwise). So you provide it with the two values that you want to add. The .__add__ variants are bound to a particular instance and you provide it with a single value that you want to add. Y

Re: operator module functions

2014-10-07 Thread Terry Reedy
On 10/7/2014 9:41 PM, Steven D'Aprano wrote: Every Python operator has a function version in the operator module: operator + has function operator.add; operator - has function operator.sub; operator * has function operator.mul; and so forth. Only, that's not quite right... according to the docu

operator module functions

2014-10-07 Thread Steven D'Aprano
Every Python operator has a function version in the operator module: operator + has function operator.add; operator - has function operator.sub; operator * has function operator.mul; and so forth. Only, that's not quite right... according to the documentation, the "official" functions are actuall