Need help optimizing first script

John J. Lee jjl at pobox.com
Fri Jun 20 14:05:54 CEST 2003


Steven Taschuk <staschuk at telusplanet.net> writes:
> Quoth John J. Lee:
[...]
> I'll disagree with John here, not about the comment/docstring
> thing, but about this function being otherwise okay.  It seems to
> be following the C convention of returning zero for success and
> nonzero for failure.  I'd suggest letting the exception propagate
> instead, catching it only when you want to do error reporting --
> which is all you use this return value for anyway.  This saves you
> the risk of forgetting to check the return value, which is one of
> the major benefits of exceptions.

Quite right of course, though it's not always a bad thing to have a
function (even one with side-effects) catch an exception and return a
value -- it can make things clearer sometimes.  But in this case,
you're right, no need for it.


John




More information about the Python-list mailing list