which is more 'pythonic' / 'better' ?

Michael Hoffman cam.ac.uk at mh391.invalid
Mon Sep 12 11:41:19 EDT 2005


Steven Bethard wrote:

 > Exceptions are for
> "exceptional" conditions, that is, things that you expect to happen 
> infrequently[1].  So if I think the code is going to fail frequently, I 
> test the condition, but if I think it won't, I use exceptions.

I think there exceptions (no pun intended) to that rule as well. A 
classic example is writing to a file. Even if you expect this to be 
impossible, it's best to just create it and trap the exception, thereby 
avoiding a race condition.
-- 
Michael Hoffman



More information about the Python-list mailing list