On 4/11/2011 10:10 AM, Natan Yellin wrote:
Hey everyone,
This is my first posting to python-list, so be gentle.

I propose the following function for the math module (which can, of
course, be rewritten in C):

      zod = lambda a, b: b and a / b

This is way too trivial to add.

zod, the zero or divide function, is useful for division where the
denominator can be 0. For example, here's one line of code
    stat = x / y
If y can be zero, that one-liner needs to be rewritten as:
    if y != 0:
         stat = x / y
    else:
         stat = 0

No. 'stat = y and x/y', which will be faster than 'stat = zod(x,y)', which does the same thing but adds a function call/

--
Terry Jan Reedy

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

Reply via email to