math.nroot [was Re: A brief question.]
Jeff Epler
jepler at unpythonic.net
Wed Jul 6 09:42:22 EDT 2005
On Tue, Jul 05, 2005 at 09:49:33PM +0100, Tom Anderson wrote:
> Are there any uses for NaN that aren't met by exceptions?
Sure. If you can naturally calculate two things at once, but one might
turn out to be a NaN under current rules.
x, y = calculate_two_things()
if isnan(x):
perform_next_step_with_only_y(y)
else:
perform_next_step_with_both(x, y)
Under your scheme, you'd have to write
try:
x, y = calculate_two_things()
except NaNException:
y = calculate_one_thing()
perform_next_step_with_only_y(y)
else:
perform_next_step_with_both(x, y)
and at the very least duplicate the code for calculating 'y', possibly
re-doing a lot of work at runtime too.
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050706/725028e6/attachment.sig>
More information about the Python-list
mailing list