[Tutor] Try/Except, A better way?
Brian Almond
BAlmond@russreid.com
Fri Mar 21 18:11:10 2003
>>> Lucid Drake <lucid@escex.com> 03/18/03 04:02PM >>>
I currently use a few Try/Except clauses in my programming and was
hoping to find a better way to do certain things.
[snip]
[Disclaimer: I'm by no means an expert at Python exceptions, and
welcome any comments on this...]
I'd argue that in a database programming context that the additional
overhead of an if/else clause or two is insignificant. Additionally,
I'd probably wrap up your application's standard DB operations in
function calls (and DB stored procedures if supported by your DB).
Finally, make the code inside each try: clause as atomic as possible.
This should make it easier to identify the source of problems. Note,
however, that this will only help if you strive to avoid blanket except
clauses.
-- Brian Almond