On 7/16/2011 2:14 AM, Chris Angelico wrote:
On Sat, Jul 16, 2011 at 6:35 PM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info>  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.

Only thing I can think of is:

import math
math.sqrt=lambda(x) x.__sqrt__(x) if x.whatever else math.sqrt(x)

I don't suppose there's a lambda version of try/catch?

ChrisA

    Why use a lambda?  Just use a def.

    A lambda with an "if" is un-Pythonic.

                                        John Nagle

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to