Steven D'Aprano wrote:
> On Fri, 01 Jan 2010 02:43:21 -0800, Jonathan Gardner wrote:
>
>> On Jan 1, 12:43 am, [email protected] (Aahz) wrote:
>>> In article <[email protected]>,
>>> Benjamin Kaplan <[email protected]> wrote:
>>> >In Python, throwing exceptions for expected outcomes is considered
>>> >very bad form [...]
>>>
>>> Who says that? I certainly don't.
>>
>> Agreed.
>>
>> int("asdf") is supposed to return what, exactly? Any language that tries
>> to return an int is horribly broken.
>
>
> [sarcasm]
> No no, the right way to deal with that is have int("asdf") return some
> arbitrary bit pattern, and expect the user to check a global variable to
> see whether the function returned a valid result or not. That's much
> better than catching an exception!
> [/sarcasm]
Or the other way around, as in C (I suspect the original ACM article assumed
C.) Look at the legion of C library subroutines that return only 0 for good
or -1 for bad, and do all their real work in side-effects (through pointers
as function arguments.) Python is a big improvement: use the function
return values for the payload, and push the out-of-band "omyghod" response
into an Exception.
Mel.
--
http://mail.python.org/mailman/listinfo/python-list