<div dir="ltr">Hey everyone,<div>This is my first posting to python-list, so be gentle.</div><div><br></div><div><meta charset="utf-8"><div>I propose the following function for the math module (which can, of course, be rewritten in C):</div>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
 zod = lambda a, b: b and a / b</blockquote><div><br></div><div>zod, the zero or divide function, is useful for division where the denominator can be 0. For example, here's one line of code</div></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
stat = x / y</blockquote><div><br></div><div>If y can be zero, that one-liner needs to be rewritten as: </div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
if y != 0:<br>    stat = x / y<br>else:<br>    stat = 0</blockquote><div>...which is 4 lines of code for simple division!</div><div><br></div><div><br></div><div>Using zod, the zero or divide function, we can write:</div>
<div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
stat = zod(x,y)</blockquote><div><br></div><div>I've encountered this issue before, but I don't know how common it is. Let me know!</div><div>Would you use zod? Or do you need ood (one or divide), in which case lets forget this altogether!</div>
<div><br></div><div dir="ltr"><div>Natan</div><div><br></div><div><span style="border-collapse:collapse;color:rgb(136, 136, 136);font-family:arial, sans-serif;font-size:13px"><div>--</div><div>blog: <a href="http://natanyellin.com/" style="color:rgb(87, 151, 176)" target="_blank">http://natanyellin.com</a></div>
<div><a href="http://natanyellin.com/" style="color:rgb(87, 151, 176)" target="_blank"></a>twitter: <a href="http://twitter.com/aantn" style="color:rgb(87, 151, 176)" target="_blank">@aantn</a></div></span></div></div><br>

</div></div>