On 24 avr, 14:28, malkarouri <[EMAIL PROTECTED]> wrote: > On Apr 24, 12:43 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > [...] > > > Not quite sure what's the best thing to do in the second case - raise a > > ValueError if args is empty, or silently return 0.0 - but I'd tend to > > choose the first solution (Python's Zen, verses 9-11). > > What's wrong with raising ZeroDivisionError (not stopping the > exception in the first place)?
Because - from a semantic POV - the real error is not that you're trying to divide zero by zero, but that you failed to pass any argument. FWIW, I'd personnaly write avg as taking a sequence - ie, not using varargs - in which case calling it without arguments would a TypeError (so BTW please s/Value/Type/ in my previous post). -- http://mail.python.org/mailman/listinfo/python-list