Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-23 Thread rantingrick
On Jul 16, 3:35 am, Steven D'Aprano wrote: > I have a custom object that customises the usual maths functions and > operators, such as addition, multiplication, math.ceil etc. > > Is there a way to also customise math.sqrt? I don't think there is, but I > may have missed something. Hmm, this ques

Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-23 Thread John Nagle
On 7/16/2011 2:14 AM, Chris Angelico wrote: On Sat, Jul 16, 2011 at 6:35 PM, Steven D'Aprano wrote: I have a custom object that customises the usual maths functions and operators, such as addition, multiplication, math.ceil etc. Is there a way to also customise math.sqrt? I don't think there

Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-16 Thread Gary Herron
On 07/16/2011 01:35 AM, Steven D'Aprano wrote: I have a custom object that customises the usual maths functions and operators, such as addition, multiplication, math.ceil etc. Is there a way to also customise math.sqrt? I don't think there is, but I may have missed something. Create a file na

Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-16 Thread Nobody
On Sat, 16 Jul 2011 19:14:47 +1000, Chris Angelico wrote: > Only thing I can think of is: > > import math > math.sqrt=lambda(x) x.__sqrt__(x) if x.whatever else math.sqrt(x) math.sqrt=(lambda sqrt=math.sqrt: lambda x: x.__sqrt__(x) if hasattr(x,'__sqrt__') else sqrt(x))() -- http://mail.pytho

Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-16 Thread Peter Otten
Steven D'Aprano wrote: > I have a custom object that customises the usual maths functions and > operators, such as addition, multiplication, math.ceil etc. > > Is there a way to also customise math.sqrt? I don't think there is, but I > may have missed something. There seem to be only three metho

Re: Is there a way to customise math.sqrt(x) for some x?

2011-07-16 Thread Chris Angelico
On Sat, Jul 16, 2011 at 6:35 PM, Steven D'Aprano wrote: > I have a custom object that customises the usual maths functions and > operators, such as addition, multiplication, math.ceil etc. > > Is there a way to also customise math.sqrt? I don't think there is, but I > may have missed something. O

Is there a way to customise math.sqrt(x) for some x?

2011-07-16 Thread Steven D'Aprano
I have a custom object that customises the usual maths functions and operators, such as addition, multiplication, math.ceil etc. Is there a way to also customise math.sqrt? I don't think there is, but I may have missed something. -- Steven -- http://mail.python.org/mailman/listinfo/python-lis